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

data Vas_DAD1819; set test.DAD1819;
array int_code[20] INTERV_CODE_01 - INTERV_CODE_20;
array ooh[20] INTERV_OOH_IND_01 - INTERV_OOH_IND_20;
Vascular=0;
do i=1 to 20;
if int_code[i] in ('1VC91','1VC93')
and ooh[i]~='Y' then Vascular=1;
end;
drop i;
if Vascular=1;
/*if Province_Issuing_HCN='ON' and Responsibility_for_Payment='01' and hcn_index='H'
and Age >=18
and hcn_Encrypted_DAR^='9999999999' */
;
run; 

I would appreciate if you can help me with the foll query:

How would I modify the query above so that only he first 5 digits of the 20 fields INTERV_CODE_01 - INTERV_CODE_20 Are checked
substr (INTERV_CODE_01,1,5) I probably need to put this in the syntax above

 

Thanks for your advice

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
if substr(int_code[i], 1, 5) in ('1VC91','1VC93')

or try the following option as well, note the addition of the colon ( : )

 

if int_code[i] in: ('1VC91','1VC93')

@Ranjeeta wrote:

data Vas_DAD1819; set test.DAD1819;
array int_code[20] INTERV_CODE_01 - INTERV_CODE_20;
array ooh[20] INTERV_OOH_IND_01 - INTERV_OOH_IND_20;
Vascular=0;
do i=1 to 20;
if int_code[i] in ('1VC91','1VC93')
and ooh[i]~='Y' then Vascular=1;
end;
drop i;
if Vascular=1;
/*if Province_Issuing_HCN='ON' and Responsibility_for_Payment='01' and hcn_index='H'
and Age >=18
and hcn_Encrypted_DAR^='9999999999' */
;
run; 

I would appreciate if you can help me with the foll query:

How would I modify the query above so that only he first 5 digits of the 20 fields INTERV_CODE_01 - INTERV_CODE_20 Are checked
substr (INTERV_CODE_01,1,5) I probably need to put this in the syntax above

 

Thanks for your advice


 

View solution in original post

7 REPLIES 7
Reeza
Super User
if substr(int_code[i], 1, 5) in ('1VC91','1VC93')

or try the following option as well, note the addition of the colon ( : )

 

if int_code[i] in: ('1VC91','1VC93')

@Ranjeeta wrote:

data Vas_DAD1819; set test.DAD1819;
array int_code[20] INTERV_CODE_01 - INTERV_CODE_20;
array ooh[20] INTERV_OOH_IND_01 - INTERV_OOH_IND_20;
Vascular=0;
do i=1 to 20;
if int_code[i] in ('1VC91','1VC93')
and ooh[i]~='Y' then Vascular=1;
end;
drop i;
if Vascular=1;
/*if Province_Issuing_HCN='ON' and Responsibility_for_Payment='01' and hcn_index='H'
and Age >=18
and hcn_Encrypted_DAR^='9999999999' */
;
run; 

I would appreciate if you can help me with the foll query:

How would I modify the query above so that only he first 5 digits of the 20 fields INTERV_CODE_01 - INTERV_CODE_20 Are checked
substr (INTERV_CODE_01,1,5) I probably need to put this in the syntax above

 

Thanks for your advice


 

Ranjeeta
Pyrite | Level 9
Thankyou
Ranjeeta
Pyrite | Level 9
data Vas_DAD1819_Sum; set test.DAD1819;
 
array int_code[20] INTERV_CODE_01 - INTERV_CODE_20;
 
array ooh[20] INTERV_OOH_IND_01 - INTERV_OOH_IND_20;
 
array status[20] INTERV_STATUS_ATTRIB_01 - INTERV_STATUS_ATTRIB_20;
 
array location[20] INTERV_OR_LOC_01 - INTERV_OR_LOC_20;
 
array duration[20] INTERV_EPISODE_DURATION_01 - INTERV_EPISODE_DURATION_20;
 
Vascular=0;
 
do i=1 to 20;
 
if substr(int_code[i], 1, 5) in : ('1VC91','1VC93', '1VX59', '1DA89', '1ET89', '1TK93', '1TV93', '1TX59', '1UE93', 
 
'1UF93', '1UI93', '1UJ93', '1UY59', '1WK93', '1WL93', '1WV59', '1JX87','1KA50', '1KA53', '1KA76', '1KA80', '1IA80',
 
'1IB57', '1IB80', '1ID57', '1ID76', '1ID80', '1ID86', '1ID87', '1JE80', '1JE87', '1JM80', '1JM87', '1JX87', '1KA50',
 
'1KA82', '1KE80', '1KG50','1KG80', '1KA76', '1KG51', '1KG57', '1KG76', '1KG80', '1KG82', '1KG87', '1JE76',
 
'1JJ76', '1JK76', '1KA76', '1KT51', '1KT76', '1KY76', '1JE57', '1JD59', '1JJ50', '1JJ51', '1JJ57', '1JJ80',
 
'1JK80', '1JM50', '1JM51', '1JM57', '1JM80', '1JM82', '1JM87', '1JW86', '1KG50', '1KG51', '1KG57', '1KG80', '1KG87', '1KT50',
 
'1KT51', '1KT80', '1KV13', '1KY50', '1KY57', '1KY76', '1KY80', '1KZ51', '1KZ86', '1SZ52', '1IC50', '1IC76', '1IC80', '1IC87',
 
'1KA57', '1KA87', '1KE50', '1KE51', '1KE57', '1KE76', '1KE87', '1NV89', '1IS53', '1JQ80', '1JU51', '1JU57', '1JU80', '1JU87','1JW86',
 
'1KQ80', '1KR50', '1KR51', '1KR57', '1KR58', '1KR59', '1KR76', '1KR80', '1KR87', '1KZ86')
 
and ooh[i]~='Y'  and status[i]~='A' and location[i] = '01'   then do;
Vascular=1;
dur=duration(i);
output;
end;
 
end;
 
drop i;
 
if Province_Issuing_HCN='ON' and Responsibility_for_Payment='01' and hcn_index='H'
 
and Age >=18
 
and hcne^='9999999999' 
 
and gender in ('M' , 'F') then output;
 
run;

I modified the SAS code above 

Would appreciate if you can advise why vascular is 1 when i have for e.g. an int code present and the OR location is not equal to 1 but still vascular is equal to 1 

how would I create a summary to show the following:

1IS53 for e.g. is in my syntax, so for all the records that have 1IS53 as an intervention what is the average and median duration

Intervention      Duration avg   Duration Median 

1IS53                   50                 55

 

ballardw
Super User

You will need to show examples of the data values of the int_code, ooh, status and location that are getting a value of Vascular that you think is incorrect. Your comparison involves all 4 values.

Ranjeeta
Pyrite | Level 9

please find attached the code highlighted in yellow is the code of interest in position 4 but the OR Location is not equal to 01  but vascular is populated as 1 

I am not sure why ?

ballardw
Super User

Are you asking for:

do i=1 to 20;
   if substr(int_code[i],1,5) in ('1VC91','1VC93')
   and ooh[i]~='Y' then Vascular=1;
end;
Ranjeeta
Pyrite | Level 9
thankyuoy

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 1003 views
  • 1 like
  • 3 in conversation