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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

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
  • 6 replies
  • 952 views
  • 0 likes
  • 3 in conversation