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

Hi Everyone,

 

I have a logistic regression program that I am using that contains a where clause. The where clause is used to to filter between a variable that has seven levels, they are 1, 3, 4, 7, 10, 13, and 14. I'd like to create a macro to go through this variable and run the logistic regression for each level, but I'm unsure as to how to go about it. Below is the logistic regression code with the where clause set to 1:

 

proc logistic data=have;
class v1(ref="3" param=ref) v2(ref="1" param=ref) v3(ref="3"
param=ref) v4(ref="White" param=ref) v5(ref="0" param=ref)
v6(ref="1" param=ref);
model dv(event="1")=v1 v2 v3 v4 v5 v6
where project = 1;
run;

I've tried doing %let project = (1, 3, 4, 7, 10, 13, 14) and having where project = &project but that gave me an error.

 

Any resources to help or guide me along would be amazing, thank you so much!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

No macros needed. Replace the WHERE statement with a BY statement.

 

by project;

 

In data set HAVE, remove any project numbers except 1, 3, 4, 7, 10, 13, 14

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

No macros needed. Replace the WHERE statement with a BY statement.

 

by project;

 

In data set HAVE, remove any project numbers except 1, 3, 4, 7, 10, 13, 14

--
Paige Miller
mitrakos
Obsidian | Level 7
Oh my god!! I was over thinking it, thank you so much!
Tom
Super User Tom
Super User

Make sure the dataset is sorted by PROJECT and then use:

by project;
where project in (1 3 4 7 10 13 14);

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 939 views
  • 2 likes
  • 3 in conversation