Need help !
I am getting error while running query and %put is not printing the values.
I am building some counts and loading into Oracle tables' numeric fields.
PROC SQL noprint;
Create Table output_Stats as
Select count(distinct(CLMS)),
count(CLMS),
count(distinct(MBRS)),
count(distinct(PROVS)),
sum(DOLLARS)
into
:&run_type._CLM_COUNT,
:&run_type._CLMS_COUNT,
:&run_type._MEM_COUNT,
:&run_type._PROV_COUNT,
:&run_type._DOLLARS
from output_x;
Quit;
%put &=&&run_type._CLM_COUNT &=&&run_type._CLMS_COUNT &=&&run_type._MEM_COUNT &=&&run_type._PROV _COUNT &=&&run_type._DOLLARS;
/* Note: Oracle table fields are numeric attributes */
%If &run_type = R %then
%do;
proc sql noprint;
update <Oracle_table>
set CLM_CNT = INPUT(&&run_type._CLM_COUNT.,4.) , /* i tried loading direct, but it was telling char error */
CLMS_CNT = INPUT(&&run_type._CLM_LINE_COUNT.,4.) ,
MEM_CNT = INPUT(&&run_type._MEMBER_COUNT.,4.) ,
PROV_CNT = INPUT(&&run_type._PROVIDER_COUNT.,4.)
where <condition>
;
Quit;
%end;
Have you tried using 3 ampersands ('&&&') for example:
CLMS_CNT = INPUT(&&&run_type._CLM_LINE_COUNT.,4.)
As you want run_type to resolve first then the whole macro variable needs to be resolved.
Amir.
What error do you get?
Please show us the entire LOG file for this code (not just the error messages) by clicking on the {i} icon, and then pasting the log into the window that appears. Do not paste the log directly into your reply, use the {i} icon.
1) %put is not printing the numbers. 2) log of error - 30303 proc sql noprint; update <table> set CLM_CNT = 30303 ! INPUT(&&run_type._CLM_COUNT.,4.) , CLMS_CNT = INPUT(&&run_type._CLM_LINE_COUNT.,4.) , _ 22 30303 ! MEMBER_CNT ERROR 22-322: Syntax error, expecting one of the following: a name, *. SYMBOLGEN: && resolves to &.
&&RUN_TYPE is never set to a value.
MLOGIC(code): %IF condition &run_type = R is TRUE
run_type is resolving correctly.I pasted log.
put statements are coming as below, actual values are not printing
&=R_CLM_COUNT &=R_CLMS_COUNT &=R_MEM_COUNT &=R_PROV_COUNT &=R_DOLLARS
Can you show us the entire log, not just the area of the code where the error appears?
Have you tried using 3 ampersands ('&&&') for example:
CLMS_CNT = INPUT(&&&run_type._CLM_LINE_COUNT.,4.)
As you want run_type to resolve first then the whole macro variable needs to be resolved.
Amir.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.