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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 723 views
  • 3 likes
  • 2 in conversation