BookmarkSubscribeRSS Feed
umesh1
Fluorite | Level 6

Hi All,

 

I have below question

 

Data

 

 

 

test;

input

 

 

ID$ Month1 Month2 Month3 Month4;

cards

 

 

;

A1 29 60 91 119

A2 89 120 0 0

A3 1 30 61 89

A4 29 19 50 78

A5 6 37 68 96

;

run

 

 

;

 

I would like to count the months when month hit over 90

 

My desire output is as below

 

 Month1Month2Month3Month4Flag
A12960911193
A289120002
A313061890
A4291950780
A563768964

 

Means in the first case A1 id is started from 29 at the month1 and continue until month3 where it reached 91 then flag is 3. On the other hand Case 3 in the month1 is 1 and month 2 is 30 which not added to 31 that time I want flag to be 0

 

Can someone help me, please

1 REPLY 1
stat_sas
Ammonite | Level 13

data want(drop=i);
set test;
flag=0;
array m(*) m:;
do i=1 to dim(m);
     if m(i)>90 then do;
     flag=i;
    leave;
end;
end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 631 views
  • 4 likes
  • 2 in conversation