Hi Team,
I have a variable called history which has 24 numbers in it.
example (111221122121112121111121) - qualifies as Ever2 /455444443211113212211221 qualifies in Ever 4
Can you advise the logic to use to create flags like in the 'history' variable if it has numbers > 2( that comes in the complete series anytime not looking at the position)then Ever2 .
I mean in that a particular variable i have 1 2months data...if the history variable has > 2 then Ever2=1, if it has >4 then Ever 4= 1;
thanks for the help.
examples of the records for history.
111111111111111111111111
888887654323221211111111
000000000000000000000000
000000000000000000000000
000000000088888888888888
111111111121111211111111
000000000000011111111111
000000000000000000000000
000000000000000000000000
888888888888888888888888
000000000000110111111211
000000000000000000000000
432232143221212212111111
000000000000000000000000
000000000000001111121111
000000000000000000000000
000000000000000000000000
111111211111111111112112
Not sure why 111221122121112121111121 qualifies as Ever2=1 given your rule is "numbers > 2"
See if below returns what you want. Else just amend the list of digits to search for.
data demo;
input digits:$24.;
Ever4 = (findc(digits,'56789')>0);
Ever2 = (Ever4=0 and findc(digits,'34')>0);
datalines;
111221122121112121113121
455444443211113212211221
111111111111111111111111
888887654323221211111111
000000000000000000000000
000000000000000000000000
000000000088888888888888
111111111121111211111111
000000000000011111111111
000000000000000000000000
000000000000000000000000
888888888888888888888888
000000000000110111111211
000000000000000000000000
432232143221212212111111
000000000000000000000000
000000000000001111121111
000000000000000000000000
000000000000000000000000
111111211111111111112112
;
proc print data=demo;
run;
Not sure why 111221122121112121111121 qualifies as Ever2=1 given your rule is "numbers > 2"
See if below returns what you want. Else just amend the list of digits to search for.
data demo;
input digits:$24.;
Ever4 = (findc(digits,'56789')>0);
Ever2 = (Ever4=0 and findc(digits,'34')>0);
datalines;
111221122121112121113121
455444443211113212211221
111111111111111111111111
888887654323221211111111
000000000000000000000000
000000000000000000000000
000000000088888888888888
111111111121111211111111
000000000000011111111111
000000000000000000000000
000000000000000000000000
888888888888888888888888
000000000000110111111211
000000000000000000000000
432232143221212212111111
000000000000000000000000
000000000000001111121111
000000000000000000000000
000000000000000000000000
111111211111111111112112
;
proc print data=demo;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.