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
 
SAS Macro value resolution.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1521
Location: Chennai

PostPosted: Tue Jul 12, 2011 1:19 pm    Post subject: SAS Macro value resolution.
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: 2441
Location: Netherlands, Amstelveen

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

http://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: 1521
Location: Chennai

PostPosted: Tue Jul 12, 2011 1:30 pm    Post subject:
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: 2441
Location: Netherlands, Amstelveen

PostPosted: Tue Jul 12, 2011 1:40 pm    Post subject:
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: 1521
Location: Chennai

PostPosted: Tue Jul 12, 2011 1:47 pm    Post subject:
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    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 exec macro in the end of edit anatol CLIST & REXX 8 Fri Sep 22, 2017 5:10 am
No new posts How to Run Rexx Macro? Kalaivignesh CLIST & REXX 5 Fri Sep 01, 2017 9:08 pm
No new posts ISREDIT MACRO NOT WORKING! :cry: kirank889 TSO/ISPF 3 Thu Aug 03, 2017 5:46 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm

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