Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable in a title1

Status
Not open for further replies.
Aug 24, 2009
2
0
0
GB
Hi,
I wish to use the value of a variable from my program in the TITLE1, but I just dont' seem to be able to get it to work.

It resolves if I use a simple piece of text, but if I try to use variable that will have it's value modified, I just get

WARNING: Apparent symbolic reference PARAM not resolved.

As a simple example, my code is:

%MACRO ONE;
DATA WORK;
SET TREND.ALERTS;
PARAM=SYSPARM();
PROC PRINT;
TITLE1 "REPORT FOR SYSTEM &PARAM";
RUN;
%MEND ONE;

%ONE;

SYSPARM is what the user will pass to the program from JCL (this is on a z/OS system), so they will know which system the report is for.

I'm probably being extremely thick here, but it's driving me mad!

Thanks
 
Looks like you're expecting the macro variable to hold a text character, which it will, but you're not populating the variable in macro code, e.g.:

%local _param;
%let param=SYSPARM();
title1 "Report for &_param.".

You're treating it as if it were a datastep variable, and you can do this but to populate the datastep variable with a char value from the macro variable you have to do:

Dsetvar="&MACVAL.";

And why no RUN; between data step and PROC PRINT? And a data=dset in your proc print? It's good form even if not necessary.

I'll confess I've never used the SYSPARM or SYSBUFF before so this may be slightly different.




 
Use
Code:
%PUT _ALL_;
to list all macro variables. If you are declaring &param in a macro, make it a global variable:

Code:
%Global PARAM;
 
Oh, I'm sorry - I misread that. &param is not resolved because you are never putting it in a macro variable.

Use a %let to define it or use symput to put it into a macro variable in a datastep.
 
If you mean to use a variable found on the local dataset with your procs, if this is a BY variable you can use the #byval in your title statement. If the variable is not the BY variable you must get the value into a macro location. (In your case the &param).

You can do this by running a datastep before your proc or like the previous posters you can set this using the %LET statement. Please note that the %LET only works on values that are available before execution, while in a DATASTEP you can tap into run-time values.

ex
Code:
%MACRO ONE;                                 
  DATA WORK;                                
   SET TREND.ALERTS;                        
   CALL SYMPUT('PARAM',sysparm());
  RUN;
TITLE "REPORT FOR SYSTEM &PARAM"; 
  PROC PRINT;
  RUN;
%MEND ONE;     
%one;

I hope this helps you. On another note always end a Datastep and a PROC with a RUN statement. I use QUIT for proc SQL and proc datsets.
Klaz
 
Thankyou very much gents, that's done the trick!

Regards

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top