BookmarkSubscribeRSS Feed
Sandhya
Fluorite | Level 6
Hi,

proc sql noprint;
select distinct(aN) into :dA1-:dA2
from dasd
group by step;
quit;

proc format;
value $tafmt 'X' = 'X (n="&dA1")'
'D' = 'D (n="&dA2")';
run;

If I attach this format to the value, I'm getting X(n=&denomA1) . The macro variable is not resolving. I even tried giving everything in double quotes in PROC FORMAT.

Thanks in Advance,
Sandy.
3 REPLIES 3
Peter_C
Rhodochrosite | Level 12
reverse those quotes
&macro_vars resolve inside doubles, but not single quotes (, at the outer level). So try
value $tafmt 'X' = "X (n='&dA1')"
'D' = "D (n='&dA2')";
run;

However, this resolves the macro variables when proc format executes. Was that what you wanted?

PeterC
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
I agree with Peter.C -- best to explain how you intend to use this narrow focus example with PROC SQL to generate suitable data values for a PROC FORMAT code execution?

Also, from my testing with the OP's code, either technique for coding the single or double quote yields the same format contents, so if you are getting "denom" there is some other problem with your code.

Suggest you use the SAS command below to see what SAS macro variables have as values:

%PUT _ALL_;

..or..

%PUT _GLOBAL_;

..or..

%PUT _LOCAL_;


Also, suggest you use the FMTLIB parameter with PROC FORMAT to see what's being generated as output to your format.

Scott Barry
SBBWorks, Inc.
Jagadishkatam
Amethyst | Level 16

Hi Sandya,

i mimicked your code using the sashelp.class dataset like below

proc sql;

select name into :name1-:name19 from sashelp.class;

quit;

The above code will create the macro variables like name1,name2....; inorder to check if the macro variable is getting resolved in the format i created i used the fmtlib option, i found that it is not resolving and the reason for this is the syntax in the proc format value

    proc format fmtlib;

      value $tafmt 'X' = 'X (n="&name1")';

    run;

the correct syntax would be as below

proc format fmtlib;

     value $tafmt 'x'="x(n=&name1)";

run;

make sure that you put only once opening and closing quote for the label as "x(n=&name1)";. Hope this will be helpful.

Thanks,

Jagadish

Thanks,
Jag

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3721 views
  • 1 like
  • 4 in conversation