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

Hello,
I am using a multi-value prompt and have the code below. The prompt is called "DRGFilterCommas". I am getting a message when I run this that "DRGFilterCommas_Count" is not initialized and this is causing the program to work as intended (see below) even though earlier in the log it displays that the value of DRGFilterCommas_Count is 1. Any ideas as to why this is?


My code:

data _null_;
length DRGsCommas_List $10000;
if symget('DRGFilterCommas_Count')>=1 then do;
DRGsCommas_List=cats("'", tranwrd("&DRGFilterCommas", ",", "','"), "'");
put DRGsCommas_List; /* just for checking */
put DRGFilterCommas_COUNT; /* just for checking */
call symputx('DRGsCommas_WHERE_CLAUSE',cats('and dr.DRGCode in (',DRGsCommas_List,')'));
call symputx('DRGsCommas_JOIN_CLAUSE','INNER JOIN SQL_STG.DRG dr ON dr.DRGKey = e.DRGKey');
call symputx('DRGs_List_Displayed',DRGFilterCommas);
end;
else do;
call symputx('DRGs_List_Displayed',"ALL");
end;
run;


Log shows the following:

%LET DRGFilterCommas_count = 1; 

NOTE: Variable DRGFilterCommas_COUNT is uninitialized.

 

Thanks,

KelseyB

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Macro variables and DATA step variables are not the same thing.  It's probably too large a topic to try to go into detail here, except to say that macro variables are not contained within a SAS DATA set. 

 

I would recommend two changes.  First, get rid of the diagnostic statement:

 

put DRGFilterCommas_COUNT; /* just for checking */

 

And change this statement:

 

if symget('DRGFilterCommas_Count')>=1 then do;

 

Based on what I think you are trying to accomplish, it should look like this:

 

if &DRGFilterCommas_Count>=1 then do;

 

Good luck.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

Macro variables and DATA step variables are not the same thing.  It's probably too large a topic to try to go into detail here, except to say that macro variables are not contained within a SAS DATA set. 

 

I would recommend two changes.  First, get rid of the diagnostic statement:

 

put DRGFilterCommas_COUNT; /* just for checking */

 

And change this statement:

 

if symget('DRGFilterCommas_Count')>=1 then do;

 

Based on what I think you are trying to accomplish, it should look like this:

 

if &DRGFilterCommas_Count>=1 then do;

 

Good luck.

KelseyB
Fluorite | Level 6

Thank you Astounding.  That worked!

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
  • 2 replies
  • 688 views
  • 0 likes
  • 2 in conversation