BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jenim514
Pyrite | Level 9

Hi!  I'm looking for help with this array.  I want to check multiple variables (Secondarydiagnosis1-20, Procedure1-20, and ProcedureHCPCS_1-13)   for a number starting with '493'.  If it begins with '493' then new variable asthma=1.  I submitted this code but it is taking a long time to process, so I'm sure there is an error!  Help is appreciated!

 

 

data asthma2.asthma_only;
set asthma2.fyall_EXCL_F;
asthma=0;
array  dx(*)secondarydiagnosis2-secondarydiagnosis20;
do i= 1 to dim(dx);
if dx(i) =: '493' then asthma=1;
array proc(*) procedure1-procedure20;
do i=1 to dim(proc);
if proc(i)=:'493' then asthma=1;
array HCPCS(*) ProcedureHCPCS_1-ProcedureHCPCS_13;
do i=1 to dim(HCPCS);
if hcpcs(i)=:'493' then asthma=1;
end;
end;
end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Yes, your DO loops should not be nested.  Moving a few END statements would work:

 

data asthma2.asthma_only;
set asthma2.fyall_EXCL_F;
asthma=0;
array  dx(*)secondarydiagnosis2-secondarydiagnosis20;
do i= 1 to dim(dx);
if dx(i) =: '493' then asthma=1;

end;
array proc(*) procedure1-procedure20;
if asthma=0 then do i=1 to dim(proc);
if proc(i)=:'493' then asthma=1;

end;
array HCPCS(*) ProcedureHCPCS_1-ProcedureHCPCS_13;
if asthma=0 then do i=1 to dim(HCPCS);
if hcpcs(i)=:'493' then asthma=1;
end;
run;

 

View solution in original post

1 REPLY 1
Astounding
PROC Star

Yes, your DO loops should not be nested.  Moving a few END statements would work:

 

data asthma2.asthma_only;
set asthma2.fyall_EXCL_F;
asthma=0;
array  dx(*)secondarydiagnosis2-secondarydiagnosis20;
do i= 1 to dim(dx);
if dx(i) =: '493' then asthma=1;

end;
array proc(*) procedure1-procedure20;
if asthma=0 then do i=1 to dim(proc);
if proc(i)=:'493' then asthma=1;

end;
array HCPCS(*) ProcedureHCPCS_1-ProcedureHCPCS_13;
if asthma=0 then do i=1 to dim(HCPCS);
if hcpcs(i)=:'493' then asthma=1;
end;
run;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 3892 views
  • 0 likes
  • 2 in conversation