I want to scan from D1 thru D7 and check if a person has 550
After checking that i also want to check if a particular code say (204) occurs after 550 or Prior to 550!!!!
D1 D2 D3 D4 D5 D6 D7
315 316 317 550 509 612 204
204 550 312 101 990 317 880
Thanks
Use WHICHN function.
data have;
input d1-d7;
f550 = whichn(550, of d1-d7);
f204 = whichn(204, of d1-d7);
before = (0 < f204 < f550);
put (_all_) (=);
cards;
315 316 317 550 509 612 204
204 550 312 101 990 317 880
run;
Use WHICHN function.
data have;
input d1-d7;
f550 = whichn(550, of d1-d7);
f204 = whichn(204, of d1-d7);
before = (0 < f204 < f550);
put (_all_) (=);
cards;
315 316 317 550 509 612 204
204 550 312 101 990 317 880
run;
Hi ,
Could you explain me what is happening in this step???
before = (0 < f204 < f550);
how are we getting before =0 and before=1???
d1=315 d2=316 d3=317 d4=550 d5=509 d6=612 d7=204 f550=4 f204=7 before=0
d1=204 d2=550 d3=312 d4=101 d5=990 d6=317 d7=880 f550=2 f204=1 before=1
Thanks
When SAS evaluates logic expressions it generates 0 for FALSE and 1 for TRUE.
So when the index for 204 is found (F204 > 0) and before the index for 550 (F204 < F550) then the expression is TRUE so the variable is set to 1.
Hi,
I was wondering if WHICHN works on missing values??
list1 list2 list3
3 . 32
missing=whichn(. , list1-list3)
we would not get 2 in this case if i am not wrong!!!!!
Thanks
try
missing=whichc(.,of list1-list3);
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.