I've made a merged dataset that I'm trying to create several variables in. My Arrays and Do loop code seems to work but with the rest of the variables I'm getting ERROR 161-185: No matching DO/SELECT statement. It does seem to be a semicolon issue and when I run various combinations of the array and do loops with the SAMPLE variable creation that part seems to work so not sure where i'm going wrong. thanks for the help!
DATA KID2019Merge;
SET IN.KID2019Merge;
T1DM=0;
ARRAY DIAG(1) $ I10_DX1;
DO i=1;
IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1;
END;
MHD=0;
ARRAY MENT(39) $ I10_DX2 - I10_DX40;
DO j=1 TO 39;
IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR SUBSTR(MENT(j),1,2)='F3'
OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR SUBSTR(MENT(j),1,2)='F7'
OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1;
END;
ADHD=0;
ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40;
DO k=1 TO 39;
IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908'
OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1;
END;
ANXIETY=0;
ARRAY MENTANX(39) $ I10_DX2 - I10_DX40;
DO l=1 TO 39;
IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010'
OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220'
OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232'
OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243'
OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409'
OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418'
OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423'
OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430'
OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320'
OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324'
OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439'
THEN ANXIETY=1;
END;
DEPR=0;
ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40;
DO m=1 TO 39;
IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323'
OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328'
OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332'
OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334'
OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340'
OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348'
OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1;
END;
OTHERMHD=0;
IF MHD = 1 THEN OTHERMHD=1;
IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0;
END;
SAMPLE=0;
IF T1DM = 1 THEN SAMPLE = 1;
IF AGE LE 9 THEN SAMPLE = 0;
IF TRAN_IN = 1 THEN SAMPLE = 0;
IF TRAN_IN = 2 THEN SAMPLE = 0;
IF TRAN_OUT = 1 THEN SAMPLE = 0;
IF TRAN_OUT = 2 THEN SAMPLE = 0;
IF DIED = 1 THEN SAMPLE = 0;
IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0;
END;
IF PAY1=1 OR PAY1=2 THEN PAYER=0;
IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1;
END;
IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0;
IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1;
IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2;
END;
SEVERITY = 0;
IF APRDRG_Severity = 0 THEN SEVERITY=0;
IF APRDRG_Severity = 1 THEN SEVERITY=1;
IF APRDRG_Severity = 2 THEN SEVERITY=2;
IF APRDRG_Severity = 3 THEN SEVERITY=3;
IF APRDRG_Severity = 4 THEN SEVERITY=5;
END;
HOSP=0;
IF HOSP_LOCTEACH = 1 THEN HOSP=0;
IF HOSP_LOCTEACH = 2 THEN HOSP=1;
IF HOSP_LOCTEACH = 3 THEN HOSP=2;
RUN;
Whenever you have an error, we need to see the LOG. Please show us the log for this data step code, from the initial DATA statement all the way down to the last NOTE after the data step. Do not chop out parts of this log.
Please click on the </> icon, and paste the log as text into the window that appears.
See below for the log
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.KID2019MERGE may be incomplete. When this step was stopped there were
0 observations and 145 variables.
WARNING: Data set WORK.KID2019MERGE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 6:06.37
cpu time 0.70 seconds
990 DATA KID2019Merge;
991 SET IN.KID2019Merge;
992
993 T1DM=0;
994
995 ARRAY DIAG(1) $ I10_DX1;
996
997 DO i=1;
998
999 IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1;
1000
1001 END;
1002
1003 MHD=0;
1004
1005 ARRAY MENT(39) $ I10_DX2 - I10_DX40;
1006
1007 DO j=1 TO 39;
1008
1009 IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR
1009! SUBSTR(MENT(j),1,2)='F3'
1010 OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR
1010! SUBSTR(MENT(j),1,2)='F7'
1011 OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1;
1012
1013 END;
1014
1015 ADHD=0;
1016 ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40;
1017 DO k=1 TO 39;
1018
1019 IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR
1019! SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908'
1020 OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1;
1021
1022 END;
1023
1024 ANXIETY=0;
1025 ARRAY MENTANX(39) $ I10_DX2 - I10_DX40;
1026 DO l=1 TO 39;
1027
1028 IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR
1028! SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010'
1029 OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR
1029! SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220'
1030 OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR
1030! SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232'
1031 OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR
1031! SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243'
1032 OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR
1032! SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409'
1033 OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR
1033! SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418'
1034 OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR
1034! SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423'
1035 OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR
1035! SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430'
1036 OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR
1036! SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320'
1037 OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR
1037! SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324'
1038 OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR
1038! SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439'
1039 THEN ANXIETY=1;
1040
1041 END;
1042
1043 DEPR=0;
1044
1045 ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40;
1046 DO m=1 TO 39;
1047
1048 IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR
1048! SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323'
1049 OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR
1049! SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328'
1050 OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR
1050! SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332'
1051 OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR
1051! SUBSTR(MENTDEP(m),1,4)='F334'
1052 OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR
1052! SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340'
1053 OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348'
1054 OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1;
1055 END;
1056
1057 OTHERMHD=0;
1058 IF MHD = 1 THEN OTHERMHD=1;
1059 IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0;
1060
1061 END;
---
161
ERROR 161-185: No matching DO/SELECT statement.
1062
1063 SAMPLE=0;
1064
1065 IF T1DM = 1 THEN SAMPLE = 1;
1066 IF AGE LE 9 THEN SAMPLE = 0;
1067 IF TRAN_IN = 1 THEN SAMPLE = 0;
1068 IF TRAN_IN = 2 THEN SAMPLE = 0;
1069 IF TRAN_OUT = 1 THEN SAMPLE = 0;
1070 IF TRAN_OUT = 2 THEN SAMPLE = 0;
1071 IF DIED = 1 THEN SAMPLE = 0;
1072 IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0;
1073
1074 END;
---
161
ERROR 161-185: No matching DO/SELECT statement.
1075
1076 IF PAY1=1 OR PAY1=2 THEN PAYER=0;
1077 IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1;
1078 END;
---
161
ERROR 161-185: No matching DO/SELECT statement.
1079
1080 IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0;
1081 IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1;
1082 IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2;
1083
1084 END;
---
161
ERROR 161-185: No matching DO/SELECT statement.
1085
1086 SEVERITY = 0;
1087 IF APRDRG_Severity = 0 THEN SEVERITY=0;
1088 IF APRDRG_Severity = 1 THEN SEVERITY=1;
1089 IF APRDRG_Severity = 2 THEN SEVERITY=2;
1090 IF APRDRG_Severity = 3 THEN SEVERITY=3;
1091 IF APRDRG_Severity = 4 THEN SEVERITY=5;
1092
1093 END;
---
161
ERROR 161-185: No matching DO/SELECT statement.
1094
1095 HOSP=0;
1096 IF HOSP_LOCTEACH = 1 THEN HOSP=0;
1097 IF HOSP_LOCTEACH = 2 THEN HOSP=1;
1098 IF HOSP_LOCTEACH = 3 THEN HOSP=2;
1099
1100 RUN;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.KID2019MERGE may be incomplete. When this step was stopped there were
0 observations and 160 variables.
WARNING: Data set WORK.KID2019MERGE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.21 seconds
cpu time 0.09 seconds
Best practice on this forum when discussing errors is to include the LOG with the code and the error. Open your log, highlight and copy the text. On the forum open a text box using the </> icon that appears above the message window and paste the text. Your specific error will indicate which line causes the problem. The text box is helpful to prevent the forum from reformatting pasted text, which often removes things like indents in code that help make things easier to follow.
Example:
56 data example; 57 set sashelp.class; 58 do i=1 to 2; 59 /* basically do nothing just have a loop*/ 60 end; 61 end; --- 161 ERROR 161-185: No matching DO/SELECT statement. 62 run;
I am not about to try to figure out from a wall of text you have a problem with out the LOG as above.
Also, if your code wasn't indented that may indicate it is time to learn why we do so. You can align the DO/End as above to tell where loops are intended to start/end.
The code as pasted shows no indent is extremely hard to follow.
Note that there is an IN operator that drastically simplifies if you want any of a list of values.
This
IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR SUBSTR(MENT(j),1,2)='F3' OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR SUBSTR(MENT(j),1,2)='F7' OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1;
can be replaced with
IF SUBSTR(MENT(j),1,2) in ('F0' 'F1' 'F2' 'F3' 'F4' 'F5' 'F6' 'F7' 'F8' 'F9' ) then MHD=1;
for example.
You might also find the =: useful.
if value =: 'F43' then <do something>;
is "if the value begins with F43" then ... So if you know your data and all of the F43XXXX values are related, such as the suspected ICD-10 (or older ICD-9) codes this resembles, with the additional characters subcodes of the main code, this might simplify code.
@alvonkorff wrote:
I've made a merged dataset that I'm trying to create several variables in. My Arrays and Do loop code seems to work but with the rest of the variables I'm getting ERROR 161-185: No matching DO/SELECT statement. It does seem to be a semicolon issue and when I run various combinations of the array and do loops with the SAMPLE variable creation that part seems to work so not sure where i'm going wrong. thanks for the help!
DATA KID2019Merge;
SET IN.KID2019Merge;
T1DM=0;
ARRAY DIAG(1) $ I10_DX1;
DO i=1;
IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1;
END;MHD=0;
ARRAY MENT(39) $ I10_DX2 - I10_DX40;
DO j=1 TO 39;
IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR SUBSTR(MENT(j),1,2)='F3'
OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR SUBSTR(MENT(j),1,2)='F7'
OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1;
END;ADHD=0;
ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40;
DO k=1 TO 39;IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908'
OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1;END;
ANXIETY=0;
ARRAY MENTANX(39) $ I10_DX2 - I10_DX40;
DO l=1 TO 39;
IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010'
OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220'
OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232'
OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243'
OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409'
OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418'
OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423'
OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430'
OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320'
OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324'
OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439'
THEN ANXIETY=1;END;
DEPR=0;
ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40;
DO m=1 TO 39;
IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323'
OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328'
OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332'
OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334'
OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340'
OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348'
OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1;
END;OTHERMHD=0;
IF MHD = 1 THEN OTHERMHD=1;
IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0;END;
SAMPLE=0;
IF T1DM = 1 THEN SAMPLE = 1;
IF AGE LE 9 THEN SAMPLE = 0;
IF TRAN_IN = 1 THEN SAMPLE = 0;
IF TRAN_IN = 2 THEN SAMPLE = 0;
IF TRAN_OUT = 1 THEN SAMPLE = 0;
IF TRAN_OUT = 2 THEN SAMPLE = 0;
IF DIED = 1 THEN SAMPLE = 0;
IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0;END;
IF PAY1=1 OR PAY1=2 THEN PAYER=0;
IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1;
END;IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0;
IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1;
IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2;END;
SEVERITY = 0;
IF APRDRG_Severity = 0 THEN SEVERITY=0;
IF APRDRG_Severity = 1 THEN SEVERITY=1;
IF APRDRG_Severity = 2 THEN SEVERITY=2;
IF APRDRG_Severity = 3 THEN SEVERITY=3;
IF APRDRG_Severity = 4 THEN SEVERITY=5;END;
HOSP=0;
IF HOSP_LOCTEACH = 1 THEN HOSP=0;
IF HOSP_LOCTEACH = 2 THEN HOSP=1;
IF HOSP_LOCTEACH = 3 THEN HOSP=2;RUN;
NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.KID2019MERGE may be incomplete. When this step was stopped there were 0 observations and 145 variables. WARNING: Data set WORK.KID2019MERGE was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 6:06.37 cpu time 0.70 seconds 990 DATA KID2019Merge; 991 SET IN.KID2019Merge; 992 993 T1DM=0; 994 995 ARRAY DIAG(1) $ I10_DX1; 996 997 DO i=1; 998 999 IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1; 1000 1001 END; 1002 1003 MHD=0; 1004 1005 ARRAY MENT(39) $ I10_DX2 - I10_DX40; 1006 1007 DO j=1 TO 39; 1008 1009 IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR 1009! SUBSTR(MENT(j),1,2)='F3' 1010 OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR 1010! SUBSTR(MENT(j),1,2)='F7' 1011 OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1; 1012 1013 END; 1014 1015 ADHD=0; 1016 ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40; 1017 DO k=1 TO 39; 1018 1019 IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR 1019! SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908' 1020 OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1; 1021 1022 END; 1023 1024 ANXIETY=0; 1025 ARRAY MENTANX(39) $ I10_DX2 - I10_DX40; 1026 DO l=1 TO 39; 1027 1028 IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR 1028! SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010' 1029 OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR 1029! SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220' 1030 OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR 1030! SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232' 1031 OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR 1031! SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243' 1032 OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR 1032! SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409' 1033 OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR 1033! SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418' 1034 OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR 1034! SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423' 1035 OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR 1035! SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430' 1036 OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR 1036! SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320' 1037 OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR 1037! SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324' 1038 OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR 1038! SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439' 1039 THEN ANXIETY=1; 1040 1041 END; 1042 1043 DEPR=0; 1044 1045 ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40; 1046 DO m=1 TO 39; 1047 1048 IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR 1048! SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323' 1049 OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR 1049! SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328' 1050 OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR 1050! SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332' 1051 OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR 1051! SUBSTR(MENTDEP(m),1,4)='F334' 1052 OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR 1052! SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340' 1053 OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348' 1054 OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1; 1055 END; 1056 1057 OTHERMHD=0; 1058 IF MHD = 1 THEN OTHERMHD=1; 1059 IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0; 1060 1061 END; --- 161 ERROR 161-185: No matching DO/SELECT statement. 1062 1063 SAMPLE=0; 1064 1065 IF T1DM = 1 THEN SAMPLE = 1; 1066 IF AGE LE 9 THEN SAMPLE = 0; 1067 IF TRAN_IN = 1 THEN SAMPLE = 0; 1068 IF TRAN_IN = 2 THEN SAMPLE = 0; 1069 IF TRAN_OUT = 1 THEN SAMPLE = 0; 1070 IF TRAN_OUT = 2 THEN SAMPLE = 0; 1071 IF DIED = 1 THEN SAMPLE = 0; 1072 IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0; 1073 1074 END; --- 161 ERROR 161-185: No matching DO/SELECT statement. 1075 1076 IF PAY1=1 OR PAY1=2 THEN PAYER=0; 1077 IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1; 1078 END; --- 161 ERROR 161-185: No matching DO/SELECT statement. 1079 1080 IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0; 1081 IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1; 1082 IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2; 1083 1084 END; --- 161 ERROR 161-185: No matching DO/SELECT statement. 1085 1086 SEVERITY = 0; 1087 IF APRDRG_Severity = 0 THEN SEVERITY=0; 1088 IF APRDRG_Severity = 1 THEN SEVERITY=1; 1089 IF APRDRG_Severity = 2 THEN SEVERITY=2; 1090 IF APRDRG_Severity = 3 THEN SEVERITY=3; 1091 IF APRDRG_Severity = 4 THEN SEVERITY=5; 1092 1093 END; --- 161 ERROR 161-185: No matching DO/SELECT statement. 1094 1095 HOSP=0; 1096 IF HOSP_LOCTEACH = 1 THEN HOSP=0; 1097 IF HOSP_LOCTEACH = 2 THEN HOSP=1; 1098 IF HOSP_LOCTEACH = 3 THEN HOSP=2; 1099 1100 RUN; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.KID2019MERGE may be incomplete. When this step was stopped there were 0 observations and 160 variables. WARNING: Data set WORK.KID2019MERGE was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.21 seconds cpu time 0.09 seconds
DATA KID2019Merge; SET IN.KID2019Merge; T1DM=0; ARRAY DIAG(1) $ I10_DX1; DO i=1; IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1; END; MHD=0; ARRAY MENT(39) $ I10_DX2 - I10_DX40; DO j=1 TO 39; IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR SUBSTR(MENT(j),1,2)='F3' OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR SUBSTR(MENT(j),1,2)='F7' OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1; END; ADHD=0; ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40; DO k=1 TO 39; IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908' OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1; END; ANXIETY=0; ARRAY MENTANX(39) $ I10_DX2 - I10_DX40; DO l=1 TO 39; IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010' OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220' OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232' OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243' OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409' OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418' OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423' OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430' OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320' OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324' OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439' THEN ANXIETY=1; END; DEPR=0; ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40; DO m=1 TO 39; IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323' OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332' OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340' OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348' OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1; END; OTHERMHD=0; IF MHD = 1 THEN OTHERMHD=1; IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0; END; SAMPLE=0; IF T1DM = 1 THEN SAMPLE = 1; IF AGE LE 9 THEN SAMPLE = 0; IF TRAN_IN = 1 THEN SAMPLE = 0; IF TRAN_IN = 2 THEN SAMPLE = 0; IF TRAN_OUT = 1 THEN SAMPLE = 0; IF TRAN_OUT = 2 THEN SAMPLE = 0; IF DIED = 1 THEN SAMPLE = 0; IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0; END; IF PAY1=1 OR PAY1=2 THEN PAYER=0; IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1; END; IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0; IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1; IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2; END; SEVERITY = 0; IF APRDRG_Severity = 0 THEN SEVERITY=0; IF APRDRG_Severity = 1 THEN SEVERITY=1; IF APRDRG_Severity = 2 THEN SEVERITY=2; IF APRDRG_Severity = 3 THEN SEVERITY=3; IF APRDRG_Severity = 4 THEN SEVERITY=5; END; HOSP=0; IF HOSP_LOCTEACH = 1 THEN HOSP=0; IF HOSP_LOCTEACH = 2 THEN HOSP=1; IF HOSP_LOCTEACH = 3 THEN HOSP=2; RUN;
@alvonkorff wrote:
DATA KID2019Merge; SET IN.KID2019Merge; T1DM=0; ARRAY DIAG(1) $ I10_DX1; DO i=1; IF SUBSTR(DIAG(i),1,3)='E10' THEN T1DM=1; END; MHD=0; ARRAY MENT(39) $ I10_DX2 - I10_DX40; DO j=1 TO 39; IF SUBSTR(MENT(j),1,2)='F0' OR SUBSTR(MENT(j),1,2)='F1' OR SUBSTR(MENT(j),1,2)='F2' OR SUBSTR(MENT(j),1,2)='F3' OR SUBSTR(MENT(j),1,2)='F4' OR SUBSTR(MENT(j),1,2)='F5' OR SUBSTR(MENT(j),1,2)='F6' OR SUBSTR(MENT(j),1,2)='F7' OR SUBSTR(MENT(j),1,2)='F8' OR SUBSTR(MENT(j),1,2)='F9' THEN MHD=1; END; ADHD=0; ARRAY MENTADHD(39) $ I10_DX2 - I10_DX40; DO k=1 TO 39; IF SUBSTR(MENTADHD(k),1,4)= 'F900' OR SUBSTR(MENTADHD(k),1,4)= 'F901' OR SUBSTR(MENTADHD(k),1,4)= 'F902' OR SUBSTR(MENTADHD(k),1,4)= 'F908' OR SUBSTR(MENTADHD(k),1,4)= 'F909' THEN ADHD=1; END; ANXIETY=0; ARRAY MENTANX(39) $ I10_DX2 - I10_DX40; DO l=1 TO 39; IF SUBSTR(MENTANX(l),1,5)='F4000' OR SUBSTR(MENTANX(l),1,5)='F4001' OR SUBSTR(MENTANX(l),1,5)='F4002' OR SUBSTR(MENTANX(l),1,5)='F4010' OR SUBSTR(MENTANX(l),1,5)='F4011' OR SUBSTR(MENTANX(l),1,6)='F40210' OR SUBSTR(MENTANX(l),1,6)='F40218' OR SUBSTR(MENTANX(l),1,6)='F40220' OR SUBSTR(MENTANX(l),1,6)='F40228' OR SUBSTR(MENTANX(l),1,6)='F40230' OR SUBSTR(MENTANX(l),1,6)='F40231' OR SUBSTR(MENTANX(l),1,6)='F40232' OR SUBSTR(MENTANX(l),1,6)='F40233' OR SUBSTR(MENTANX(l),1,6)='F40240' OR SUBSTR(MENTANX(l),1,6)='F40241' OR SUBSTR(MENTANX(l),1,6)='F40243' OR SUBSTR(MENTANX(l),1,6)='F40248' OR SUBSTR(MENTANX(l),1,6)='F40298' OR SUBSTR(MENTANX(l),1,4)='F408' OR SUBSTR(MENTANX(l),1,4)='F409' OR SUBSTR(MENTANX(l),1,4)='F410' OR SUBSTR(MENTANX(l),1,4)='F411' OR SUBSTR(MENTANX(l),1,4)='F413' OR SUBSTR(MENTANX(l),1,4)='F418' OR SUBSTR(MENTANX(l),1,4)='F419' OR SUBSTR(MENTANX(l),1,3)='F42' OR SUBSTR(MENTANX(l),1,4)='F422' OR SUBSTR(MENTANX(l),1,4)='F423' OR SUBSTR(MENTANX(l),1,4)='F424' OR SUBSTR(MENTANX(l),1,4)='F428' OR SUBSTR(MENTANX(l),1,4)='F429' OR SUBSTR(MENTANX(l),1,4)='F430' OR SUBSTR(MENTANX(l),1,5)='F4310' OR SUBSTR(MENTANX(l),1,5)='F4311' OR SUBSTR(MENTANX(l),1,5)='F4312' OR SUBSTR(MENTANX(l),1,5)='F4320' OR SUBSTR(MENTANX(l),1,5)='F4321' OR SUBSTR(MENTANX(l),1,5)='F4322' OR SUBSTR(MENTANX(l),1,5)='F4323' OR SUBSTR(MENTANX(l),1,5)='F4324' OR SUBSTR(MENTANX(l),1,5)='F4325' OR SUBSTR(MENTANX(l),1,5)='F4329' OR SUBSTR(MENTANX(l),1,4)='F438' OR SUBSTR(MENTANX(l),1,4)='F439' THEN ANXIETY=1; END; DEPR=0; ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40; DO m=1 TO 39; IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323' OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332' OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340' OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348' OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN DEPR=1; END; OTHERMHD=0; IF MHD = 1 THEN OTHERMHD=1; IF ADHD=1 OR ANXIETY=1 OR DEPR=1 THEN OTHERMHD=0; END; SAMPLE=0; IF T1DM = 1 THEN SAMPLE = 1; IF AGE LE 9 THEN SAMPLE = 0; IF TRAN_IN = 1 THEN SAMPLE = 0; IF TRAN_IN = 2 THEN SAMPLE = 0; IF TRAN_OUT = 1 THEN SAMPLE = 0; IF TRAN_OUT = 2 THEN SAMPLE = 0; IF DIED = 1 THEN SAMPLE = 0; IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0; END; IF PAY1=1 OR PAY1=2 THEN PAYER=0; IF PAY1=3 OR PAY1=4 OR PAY1=5 OR PAY1=6 THEN PAYER=1; END; IF AGE=10 OR AGE=11 OR AGE=12 OR AGE=13 THEN AGECAT=0; IF AGE=14 OR AGE=15 OR AGE=16 OR AGE=17 THEN AGECAT=1; IF AGE=18 OR AGE=19 OR AGE=20 THEN AGECAT=2; END; SEVERITY = 0; IF APRDRG_Severity = 0 THEN SEVERITY=0; IF APRDRG_Severity = 1 THEN SEVERITY=1; IF APRDRG_Severity = 2 THEN SEVERITY=2; IF APRDRG_Severity = 3 THEN SEVERITY=3; IF APRDRG_Severity = 4 THEN SEVERITY=5; END; HOSP=0; IF HOSP_LOCTEACH = 1 THEN HOSP=0; IF HOSP_LOCTEACH = 2 THEN HOSP=1; IF HOSP_LOCTEACH = 3 THEN HOSP=2; RUN;
Why are those END that I have highlighted there at all? End closes a Do/end or a Select/end block.
Great question, thanks so much for the help, that was the problem!
Hello @alvonkorff,
Once you have deleted those stray END statements (which don't belong to a DO-END block and therefore are causing the error messages) and hopefully simplified the code according to ballardw's suggestions, make sure you correct this logical error
@alvonkorff wrote:
IF DISPUNIFORM = 2 OR 5 OR 6 OR 7 OR 20 THEN SAMPLE = 0;
to
IF DISPUNIFORM IN (2 5 6 7 20) THEN SAMPLE = 0;
You mean "if DISPUNIFORM has any of the values listed", but SAS would interpret the 5 in "OR 5" as the Boolean value TRUE (because the Boolean value of any non-missing, non-zero numeric value is TRUE) and hence set SAMPLE = 0 regardless of the value of DISPUNIFORM.
@alvonkorff And for processing efficiency and improved "readability" you could also change logic like...
IF T1DM = 1 THEN SAMPLE = 1;
IF AGE LE 9 THEN SAMPLE = 0;
IF TRAN_IN = 1 THEN SAMPLE = 0;
IF TRAN_IN = 2 THEN SAMPLE = 0;
IF TRAN_OUT = 1 THEN SAMPLE = 0;
IF TRAN_OUT = 2 THEN SAMPLE = 0;
...to...
IF DIED = 1 THEN SAMPLE = 0;
else IF TRAN_OUT = 2 THEN SAMPLE = 0;
else IF TRAN_OUT = 1 THEN SAMPLE = 0;
else IF TRAN_IN = 2 THEN SAMPLE = 0;
else IF TRAN_IN = 1 THEN SAMPLE = 0;
else IF AGE LE 9 THEN SAMPLE = 0;
else IF T1DM = 1 THEN SAMPLE = 1;
and also here instead of...
DEPR=0;
ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40;
DO m=1 TO 39;
IF SUBSTR(MENTDEP(m),1,4)='F320' OR SUBSTR(MENTDEP(m),1,4)='F321' OR SUBSTR(MENTDEP(m),1,4)='F322' OR SUBSTR(MENTDEP(m),1,4)='F323'
OR SUBSTR(MENTDEP(m),1,4)='F324' OR SUBSTR(MENTDEP(m),1,4)='F325' OR SUBSTR(MENTDEP(m),1,4)='F328' OR SUBSTR(MENTDEP(m),1,4)='F328'
OR SUBSTR(MENTDEP(m),1,4)='F329' OR SUBSTR(MENTDEP(m),1,4)='F330' OR SUBSTR(MENTDEP(m),1,4)='F331' OR SUBSTR(MENTDEP(m),1,4)='F332'
OR SUBSTR(MENTDEP(m),1,4)='F333' OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F334'
OR SUBSTR(MENTDEP(m),1,4)='F334' OR SUBSTR(MENTDEP(m),1,4)='F338' OR SUBSTR(MENTDEP(m),1,4)='F339' OR SUBSTR(MENTDEP(m),1,4)='F340'
OR SUBSTR(MENTDEP(m),1,4)='F341' OR SUBSTR(MENTDEP(m),1,4)='F348'
OR SUBSTR(MENTDEP(m),1,4)='F349' OR SUBSTR(MENTDEP(m),1,4)='F39' THEN
DEPR=1;
END;
...limit looping and how many times you use the substr() function to the necessary minimum...
DEPR=0;
ARRAY MENTDEP(39) $ I10_DX2 - I10_DX40;
DO m=1 TO dim(MENTDEP);
if SUBSTR(MENTDEP(m),1,4) in ('F320','F321','F322','F323','F324','F325','F328','F328','F329','F330','F331','F332','F333',
'F334','F334','F334','F338','F339','F340','F341','F348','F349','F39') then
do;
DEPR=1;
leave;
end;
END;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.