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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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