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

SAS Macro value resolution.


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

Global Moderator


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

PostPosted: Tue Jul 12, 2011 1:19 pm
Reply with quote

Hello,
I am trying to understand how SAS macro variables are getting resolved,
In the below program,
Code:
%let text = lower case values;
%let val  = %upcase(&text);   
%put &val;                   
%let prog = %nrstr(%put &val);
&prog;


I was expecting that the line 5 statement &PROG would get resolved to %put &val and then this %put statement would inturn produce "LOWER CASE VALUES" on log,
But I got the below resolution error message on the log,
Code:
1    %let text = lower case values;                                     
2    %let val  = %upcase(&text);                                       
3    %put &val;                                                         
LOWER CASE VALUES                                                       
4    %let prog = %nrstr(%put &val);                                     
5    &prog;                                                             
NOTE: Line generated by the macro variable "PROG".                     
5     %put &val                                                         
      -                                                                 
      180                                                               
                                                                       
ERROR 180-322: Statement is not valid or it is used out of proper order.

Could you please let me know why the &prog; is not producing "LOWER CASE VALUES".
I am not looking to correct the program or modify it somehow since this is only a self-learning exercise to undrstand the working,
but would like to understand how the values are resolved during execution and how this error occurs.

I read about Input stack then tokenisation then word processor of macro execution, but they sound greek and latin to a beginner :S
Thanks for viewing.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Jul 12, 2011 1:25 pm
Reply with quote

support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000206943.htm
Back to top
View user's profile Send private message
vasanthz

Global Moderator


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

PostPosted: Tue Jul 12, 2011 1:30 pm
Reply with quote

Hello Peter,
Thank you for the link,
But I am still not clear of the difference between the third line "%put &val;"
and the 5th line "&prog;" which inturn gets resolved to "%put &val;" (3rd line)

The 3rd line generates an output, but the 5th line does not :S

Regards,
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue Jul 12, 2011 1:40 pm
Reply with quote

The %NRSTR function prevents the & from triggering macro variable resolution.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


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

PostPosted: Tue Jul 12, 2011 1:47 pm
Reply with quote

Thanks Peter.
I think it makes sense now, I misunderstood the program thinking that the NRSTR was in effect with an argument only on one line and not on the next line in which refers the argument.
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 Access to macro definitions PL/I & Assembler 4
No new posts PRINTOUT macro PL/I & Assembler 0
No new posts create rexx edit Macro that edits the... CLIST & REXX 3
No new posts Issues with executing a REXX MACRO th... TSO/ISPF 4
No new posts Facing issue in Run Edit Macro Job CLIST & REXX 9
Search our Forums:

Back to Top