BookmarkSubscribeRSS Feed
ChuksManuel
Pyrite | Level 9

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

 

ThanksCapture.JPG

2 REPLIES 2
ChuksManuel
Pyrite | Level 9

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.

 

Astounding
PROC Star
Your sample program is only vaguely related to your description of the problem. Using the description as a guide, there is no need to create a flag. Instead, here is what would go inside your DO loop:

do over cpt;
if cpt in ('99281', '99282', '99283', '99284', '99285')
then do;
code = cpt;
output;
end;
end;

Then after the DATA step is complete:

proc freq;
tables code;
run;

Of course, this could be totally wrong.

On a side note, have you considered using a more modern syntax for arrays? SAS stopped supporting implicit arrays in the 1980s.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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
  • 2 replies
  • 836 views
  • 0 likes
  • 2 in conversation