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;
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.