BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma8
Quartz | Level 8
Hi.

data have ;
input id score_a score_b score_c score_d fee_a fee_b fee_c fee_d want;
cards ;
111111 70 85 50 60 1 0 3 5 70
222222 80 65 80 70 0 1 4 1 65
333333 60 70 70 100 0 1 0 1 70
444444 60 90 100 100 0 0 0 0 .
555555 40 50 80 70 1 1 1 1 40
666666 75 80 60 60 4 2 0 1 60
;
run ;

I have this above data and I would like to find the first fee=1 and the corresponding score (see column want), if there is no fee=1 then want code as missing. How can I do that?
Thank you!
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @Emma8  Please try-

data want;
 set have;
 array f fee_:;
 array s score_:;
 _n_=whichn(1, of f(*));
 if _n_ then  want=s(_n_);
run;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

Hi @Emma8  Please try-

data want;
 set have;
 array f fee_:;
 array s score_:;
 _n_=whichn(1, of f(*));
 if _n_ then  want=s(_n_);
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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