BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASAna
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Amir
PROC Star

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.

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
SASAna
Quartz | Level 8
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 &.
PaigeMiller
Diamond | Level 26

&&RUN_TYPE is never set to a value.

--
Paige Miller
SASAna
Quartz | Level 8
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

PaigeMiller
Diamond | Level 26

Can you show us the entire log, not just the area of the code where the error appears?

--
Paige Miller
Amir
PROC Star

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1366 views
  • 0 likes
  • 3 in conversation