Hello experts,
I have 10 Cpt codes for emergency visits (cpt1-cpt10). And the ER visit codes are from 99281, 99282, 99283, 99284 and 99285 (in increasing order of patient severity)... I want to find out how many of each of these ER visit codes there are in the dataset. Do i need to use an array and initialize a flag statement?
My a subset of my data looks like this
Thanks
This is an inital code that i've written.
data three; set tmp1.lesson2emergencyvisits;
array cpt $ cpt1-cpt10;
a_one=0;
a_two=0;
a_three=0;
a_four=0;
a_five=0;
do over cpt;
if cpt= '99281' then flag= a_one+1;
if cpt = '99282' then flag2 = a_two+1;
if cpt = '99283' then flag3 = a_three+1;
if cpt = '99284' then flag4= a_four+1;
if cpt = '99285' then flag5 = a_five+1;
end; run;
proc freq data= three; table flag; run;
proc freq data=three; table flag1*flag2*flag3*flag4*flag5/list; run;
I am trying to create a flag and then to get all the observations in each flag.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.