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;
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
  • 1 reply
  • 715 views
  • 3 likes
  • 2 in conversation