BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jcis7
Pyrite | Level 9
 %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.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

4 REPLIES 4
Reeza
Super User

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?

Kurt_Bremser
Super User

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.

jcis7
Pyrite | Level 9

Thanks everyone. I figured out what I did wrong.

Reeza
Super User

@jcis7 please mark one of the solutions as correct.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 4 replies
  • 727 views
  • 0 likes
  • 3 in conversation