%if &table=3 or &table=3a or &table=3b or &table=3c %then %do; proc sql; create table want1 as select a.county, c.count, c.imm, c.missing, c.med, c.bel, c.oth, c.over from counties as a left join have as c on a.county=c.county; quit; %end;
I inherited a program am trying to modify it.
table 'have' has a list of 50 counties along with additional variables.
table 'counties' has a list of all desired 60 counties, one per rown
table 'want' I need all 60 counties listed, one per row, in the table 'counties' joined by county name to the table 'have' with the following column names:
county count imm missing med bel oth over
When I run the sql code without using the or statement (i,e, repeat , the sql statement works (I get 60 rows). If I run the macro just with one table name, I still am getting only 50 rows as output. How do I troubleshoot? Thanks.
If you get different outcomes from this step, then it is not the %if condition, but changes in the input datasets. There is nothing dynamic in the SQL, so it will always work the same, but the outcome will depend on the input datasets.
From what you've shown, your code will only ever run once, there's nothing dynamic in it, so the results will be the same regardless of the table name(s) as long as they meet one of the table names in the OR list.
Are you expecting it to run multiple times?
If you get different outcomes from this step, then it is not the %if condition, but changes in the input datasets. There is nothing dynamic in the SQL, so it will always work the same, but the outcome will depend on the input datasets.
Thanks everyone. I figured out what I did wrong.
@jcis7 please mark one of the solutions as correct.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.