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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 3 replies
  • 590 views
  • 2 likes
  • 3 in conversation