Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Global Variable in SAS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: Global Variable in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Thu Oct 03, 2013 5:04 pm    Post subject:
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    Post subject:
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: 1522
Location: Chennai

PostPosted: Thu Oct 03, 2013 6:59 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us