IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Global Variable in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Subbulakshmi yogesh

New User


Joined: 28 Sep 2011
Posts: 8
Location: india

PostPosted: Thu Oct 03, 2013 1:34 pm
Reply with quote

hi i am creating a Global variable and trying to use that global variable inside one data step. its not getting resolved. code below,

%GLOBAL NUM_SPA;

DATA _NULL_;
...
CALL SYMPUT('NUM_SPA',ROUND(NUM_VAL));
RUN ;

DATA DD2.DATEVT;
SET MRG_EVNT_DATE;
%MACRO MOST_RECENT_SPA ;
%PUT 'CHECK NUMSPA :' &NUMSPA;
SPA_Date_Last = max(SPA_Date_1, %do i = 1 %to &num_spa-1; SPA_DATE_&i. , %end ; SPA_Date_&num_spa.) ;
%MEND MOST_RECENT_SPA ;

%MOST_RECENT_SPA;

run;

when i run it num_spa is not getting resolved. when i print it for checking purpose its like,

'CHECK NUM_SPA :' 4 with some leading space.

so i doubt NUM_SPA is created a character, when i try to compress the variable its not getting compressed. Can any one tell me wat could be the error in this code.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Oct 03, 2013 5:04 pm
Reply with quote

Have you tried
Code:

CALL SYMPUT('NUM_SPA',COMPRESS(ROUND(NUM_VAL)));


Also, see the difference in results when using
&NUM_SPA. and "&NUM_SPA."

Have a play with
Code:

DATA _NULL_;                                                 
  DEF =  'CHECK NUMBER 01 : '|| &NUM_SPA. ||' '|| "&NUM_SPA.";   
  PUT DEF;                                                   
  PUT ' ';                                                   
  PUT @01 'CHECK NUMBER 02 : '                               
       +1 "&NUM_SPA."                                       
       +1 "&NUM_SPA.";                                     
  PUT ' ';                                                   
  PUT @01 'CHECK NUMBER 03 : ' "&NUM_SPA.";                 
  RUN;                                                       
Back to top
View user's profile Send private message
Subbulakshmi yogesh

New User


Joined: 28 Sep 2011
Posts: 8
Location: india

PostPosted: Thu Oct 03, 2013 5:53 pm
Reply with quote

Thanks for you reply. I found the solution in a different way. my problem is
SPA_Date_&num_spa.) - the last date. when i give the mprint option, it gives me like (SPA_Date_ 4) with a space in it.
so i changed it as SPA_Date_&i. so it comes out of the do loop i value will be equal to num_spa value so it worked...

it pick up correctly for SPA_DATE_&i.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Thu Oct 03, 2013 6:59 pm
Reply with quote

Hello,

Glad you got your issue resolved.

Just one other thing,
Quote:
so i doubt NUM_SPA is created a character,

All macro variables are character data types.
%let x= 10;
10 is treated as character.

Regards,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top