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

Hello,

                i have simple proc sql statement to create macro variable name custid. I use this custid macro variable in other sql shown below to create table cust_dtl.

The problem arises when custid has 0 rows selected from cust_tbl which then gives error in sas log saying apparent symbolic reference not resolved. How do i replace value of custid with default value of 00 so it can be used in other proc sql without error.

 

proc sql noprint;
            select distinct cust_id format 15. into :custid SEPARATED BY ','
            from wk.cust_tbl
            ;
            quit;
                       

               %put &custid. ;

 

proc sql;

create table cust_dtl as

select name,dob from cust_det

where cust_id in (&custid.);

quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Do it the other way around.  Add this statement just before the first PROC SQL:

 

%let custid=00;

 

Then if PROC SQL selects no rows, it will leave CUSTID alone.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

Do it the other way around.  Add this statement just before the first PROC SQL:

 

%let custid=00;

 

Then if PROC SQL selects no rows, it will leave CUSTID alone.

sasuser101
Obsidian | Level 7
thank you for simple and effective solution.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1990 views
  • 5 likes
  • 2 in conversation