0
votes

I need to store ​​macro variable values ​​in the SAS dataset like this:

PROC SQL;
    SELECT SUM(Invoice)/1000 FORMAT COMMAX18.2 INTO :val01 FROM SASHELP.CARS;
QUIT;
%PUT &val01.;

PROC SQL;
    SELECT COUNT(Model) FORMAT COMMAX12. INTO :val02 FROM SASHELP.CARS;
QUIT;
%PUT &val02.;

PROC SQL;
    SELECT SUM(MSRP)/1000000 FORMAT COMMAX18.2 INTO :val03 FROM SASHELP.CARS;
QUIT;
%PUT &val03.;

data WORK.teste;
   input col01 $ col02 $ col03 $;
   datalines;
Invoice &val01.  k
Model   &val02.  un
MSRP    &val03.  mi
;


proc print data=WORK.teste;
run;

The desired result would be:

Obs  col01    col02      col03
1    Invoice  12.846,29  k
2    Model    428        un
3    MSRP     14,03      mi

However, ​​macro variable references are not being interpreted by SAS as ​​macro variable values.

And the result is:

Obs  col01    col02    col03
1    Invoice  &val01.  k
2    Model    &val02.  un
3    MSRP     &val03.  mi

How to make the SAS understand &val01. as a macro variable name, rather than a string.

Anyone would like a tip, please.