%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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: