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

if Alpha=2 then plan =3;

if Alpha=3 then plan =1;

else if Alpha=4 then plan =0;

 

if Beta=2 then plan =2;

else Beta=3 then plan =1;

else if Beta=4 then plan =0;

 

I want to get the minimum/lower plan under the below condition? so as an answer I need beta here

if Alpha=2 then plan =3;

if Beta=2 then plan =2;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

If I understand you correctly, create two variables (plan_Alpha and plan_Beta) instead of one.  Then it's easy to obtain the result you describe:

 

if alpha=beta=2 then plan = min(plan_alpha, plan_beta);

 

 

View solution in original post

6 REPLIES 6
Astounding
PROC Star

Assuming you have correctly calculated Alpha and Beta (and looking at your logic it appears it needs a little cleaning up), you could use:

 

plan = min(alpha, beta);

animesh123
Obsidian | Level 7
The code is correct plan=min (alpha, beta) will give the min of all alpha
and beta

I just need min condition when both alpha and beta hit 2
Astounding
PROC Star

To get that, you will need to show more of the data.  What you posted doesn't illustrate either variable "hitting 2".

animesh123
Obsidian | Level 7
The code is correct
plan=min (alpha, beta) will give the min of all alpha and beta
if Alpha=3 then plan =1;
else if Alpha=4 then plan =0;

if Beta=3 then plan =1;
else if Beta=4 then plan =0;

plan=min (alpha, beta) will give the min of all alpha and beta
Just required the min condition of the below code when both Alpha=2 and Beta=2

if Alpha=2 then plan =3;
if Beta=2 then plan =2;
animesh123
Obsidian | Level 7
Just required the min plan of the below code when both Alpha=2 and Beta=2
Astounding
PROC Star

If I understand you correctly, create two variables (plan_Alpha and plan_Beta) instead of one.  Then it's easy to obtain the result you describe:

 

if alpha=beta=2 then plan = min(plan_alpha, plan_beta);

 

 

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 16. 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
  • 6 replies
  • 601 views
  • 0 likes
  • 2 in conversation