Use PROC FREQ?
In general I have use pass thru SQL to handle databases where letting SAS generate the SQL does not work.
If the issue is that using 1 and 0 is causing the database to default to using a small integer that cannot store the actual total you might be able to get it to work properly by just putting in a decimal place so that it generates floating point variable instead. So something like this:
sum(case when (xxx=1) then 1.0 else 0.0 end) as total
SAS doesn't care. All numbers are floating point numbers to SAS.
Hello,
I have a problem with this code; I don't understand why it does not pick fire-related incidents.
Steps a and b are to show whether the hospitalization is related to CO poisoning yes or no
step c is to identify fire-related CO poisoning; I think either step c or step f has a problem, but I am not sure what it is because I expect to see fire-related incidents, but as it is, it returns nothing for fire-related incidents.
All other parts seem to be working well!
If anyone can identify something that may be off, I would appreciate it!
* sub-step A;
substr(dx18,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx17,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') then COyes_step2a10 = 1;
* sub-step B;
substr(dx18,1,5) in ('T5802', 'T5803', 'T5812', 'T5813', 'T5892', 'T5893') or substr(dx17,1,6) in ('T582X2', 'T582X3', 'T588X2', 'T588X3') then COno_step2b10 = 1;
if COyes_step2a10 = 1 and COno_step2b10 ~= 1 then COpoisoning = 1;
* sub-step c;
substr(dx18,1,3) in ('X00', 'X01', 'X02', 'X03', 'X04', 'X05', 'X06', 'X08') then CO_fire10 = 1;
* sub-step d;
substr(dx18,1,5) in ('T5801', 'T5811', 'T5891') or substr(dx17,1,6) in ('T582X1', 'T588X1') then CO_nonfire_prelim10 = 1;
if CO_fire10 ~= 1 and CO_nonfire_prelim10 = 1 then CO_nonfire10 = 1;
* sub-step e;
substr(dx18,1,5) in ('T5804', 'T5814', 'T5894') or substr(dx17,1,6) in ('T582X4', 'T588X4') then CO_unknown_prelim1_10 = 1;
if CO_fire10 ~= 1 and CO_unknown_prelim1_10 = 1 then CO_unknown_prelim2_10 = 1;
if CO_fire10 = 1 and CO_nonfire10 = 1 then CO_unknown_prelim3_10 = 1;
if CO_unknown_prelim2_10 = 1 or CO_unknown_prelim3_10 = 1 then CO_unknown10 = 1;
* sub-step f;
if CO_fire10 = 1 then Cause = 1;*fire related ;
if CO_nonfire10 = 1 then Cause = 2;*not fire related;
if CO_unknown10 = 1 then Cause = 3;*Unknown mechanism or intent;
if CO_fire10 = 1 and CO_nonfire10 = 1 then Cause = 3;
if CO_fire10 = 1 and CO_unknown10 = 1 then Cause = 3;
if CO_nonfire10 = 1 and CO_unknown10 = 1 then Cause = 3;
HealthOutcomeID=3;
MonthlyHosp=0;
run;
Not sure how this relates to the rest of the thread but the code snippet you posted is invalid.
In particular the statements like this:
substr(dx18,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx17,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') then COyes_step2a10 = 1;
Did you mean for those to be IF/THEN statements?
IF substr(dx18,1,5) in ('T5801' 'T5804' 'T5811' 'T5814' 'T5891' 'T5894')
or substr(dx17,1,6) in ('T582X1' 'T582X4' 'T588X1' 'T588X4')
then COyes_step2a10 = 1;
Also what did you intend by using ~= in one of your tests? Did you mean not equal? Or something else? I think that SAS will accept ~ as a replacement for the NOT character that existed on the EBCDIC character sets used by the IBM mainframes it was original written on. I know it will accept ^ as a replacement for the NOT character. It will also accept the keyword NOT. Or the mnemonic NE (for not equal). But if your variables are intended as binary flags and have only been assigned values of 1 (TRUE) or 0 (FALSE) or any missing value (also FALSE) then you can just treat the variables themselves as boolean expressions.
if COyes_step2a10 and not COno_step2b10 then COpoisoning = 1;
If you use SUBSTR() at the start of a statement that means you want to replace part of the variable mentioned with the character expression to the right of the equal sign. Something like:
substr(dx18,1,5)= '12345' ;
Are you asking for help with your logic? If so can you explain more clearly what you are testing for with these IF/THEN statements and boolean flags? Can you provide example data that causes your logic to not behave in the way you expect? Show what result you want for that input. Try to reduce the data and variables to just enough to demonstrate the issue (frequently just going through that process will normally show you the solution.)
Yes, it is an if-then statement. I did not provide the whole. It starts from dx to dx18, so it was not the whole code. I am testing the logic, which simply is if step a = 1 and step c= 1, then column CO_fire(CD) should be flagged as 1 and not missing as shown in the picture. ~= mean NE, the three conditions are fire-incident, non-fire, and Unknown. It seems like it works for non-fire, so I do not know why it would not work for fire incidents.
The code was very long below is just step A
* sub-step A;
if substr(dx,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx1,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx1,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx2,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx2,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx3,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx3,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx4,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx4,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx5,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx5,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx6,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx6,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx7,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx7,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx8,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx8,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx9,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx9,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx10,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx10,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx11,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx11,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx12,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx12,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx13,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx13,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx14,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx14,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx15,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx15,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx16,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx16,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx17,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx16,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') or
substr(dx18,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx17,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') then COyes_step2a10 = 1;
Are you having trouble setting the initial 0/1 variables (the ones with the long IF condition)?
Your picture of the data seems to have a variable named COyes_step2a10 with 1 on every observation. Is that what you are having trouble with? Is that variable already on the input dataset? If so then make sure to set it to 0 at the appropriate time. Perhaps by adding an ELSE statement to your IF/THEN statement? Or is this a picture of the data after running the step that creates COyes_step2a10? I cannot tell from the photograph whether or not all of those observations have at least one of the mentioned codes.
Remember to post example data as text (preferable a working data step) and not as pictures. To test your logic there is no need for so many DX variables. Just a couple should be enough to make some example cases that demonstrate what you are trying to do.
Are you having trouble with the logic that combines them? If so then just test that separately with a simple program to tries all possible combinations of the input flags. Something like:
data test;
do A=0,1;
do B=0,1;
C= (A and NOT B);
output;
end;
end;
run;
@Tom The variable named COyes_step2a10 with 1 on every observation is acceptable because the first step was identifying all CO poisoning cases. The picture of the data is after running the step that creates COyes_step2a10. I think the issue may be with the logic that combines them; I tried the code you provided, which gives all possible combinations for CO_fire 1, which is great, but I need to count the incident by fire, Non-fire, and Unknown. so if one of the columns, like line three, shows 1 for non-fire, it cannot be counted again as a fire incident in the last column. The fire incident should be explicitly fire, and the other columns for non-fire and unknown should be 0.
dx | COyes_step2a10 | COno_step2b10 | COpoisoning | CO_fire10 | CO_nonfire_prelim10 | CO_nonfire10 | CO_unknown_prelim1_10 | CO_fire12 | Cause | CO_unknown10 | HealthOutcomeID | MonthlyHosp | CO_fire1 |
. | 1 | . | 1 | . | 0 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 0 | 1 | 1 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 0 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 0 | 1 | 1 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 0 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
. | 1 | . | 1 | . | 0 | 1 | 1 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 1 | 1 | 0 | . | 3 | . | 3 | 0 | 1 |
. | 1 | . | 1 | . | 0 | 1 | 0 | . | 3 | . | 3 | 0 | 0 |
Not sure I follow but it sounds like you want to create a hierarchy where some conditions are more important than others. In that case make a multi-level variable to store the result of which level in the hierarchy each observations is classified.
Say you have three flags A,B and C and you want to check them in that order and create a 4 different results, 'A','B','C',or 'NONE'.
length result $4;
if A then result='A';
else if B then result='B';
else if C then result='C';
else result='None';
Then you can use some tool to count how many observations for each value of RESULT. So perhaps PROC FREQ.
Bad data design. Transpose to long, discarding all missing values on the way.
proc transpose data=have out=long (rename=(col1=dx) where=(dx ne ""));
by vhikey;
var dx:;
run;
Then it is
data want;
set long;
by vhikey;
retain coyes_step2a10;
if first.vhikey then coyes_step2a10 = 0;
if
substr(dx,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or
substr(dx,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4')
then coyes_step2a10 = 1;
if last.vhikey;
drop dx _name_;
run;
@Kurt_Bremser , should the proc transpose go after the data step? Also, does anyone know how to shorten this code? The dx runs from 1 to 18. I need to flag when the CO hospitalization was fire-related, non-fire and Unknown.
* sub-step A;
If substr(dx18,1,5) in ('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(dx17,1,6) in ('T582X1', 'T582X4', 'T588X1', 'T588X4') then COyes_step2a10 = 1;
* sub-step B;
if substr(dx18,1,5) in ('T5802', 'T5803', 'T5812', 'T5813', 'T5892', 'T5893') or substr(dx17,1,6) in ('T582X2', 'T582X3', 'T588X2', 'T588X3') then COno_step2b10 = 1;
if COyes_step2a10 = 1 and COno_step2b10 ~= 1 then COpoisoning = 1;
* sub-step c;
if substr(dx18,1,3) in ('X00', 'X01', 'X02', 'X03', 'X04', 'X05', 'X06', 'X08') then CO_fire10 = 1;
* sub-step d;
substr(dx18,1,5) in ('T5801', 'T5811', 'T5891') or substr(dx17,1,6) in ('T582X1', 'T588X1') then CO_nonfire_prelim10 = 1;
if CO_fire10 ~= 1 and CO_nonfire_prelim10 = 1 then CO_nonfire10 = 1;
* sub-step e;
if substr(dx18,1,5) in ('T5804', 'T5814', 'T5894') or substr(dx17,1,6) in ('T582X4', 'T588X4') then CO_unknown_prelim1_10 = 1;
if CO_fire10 ~= 1 and CO_unknown_prelim1_10 = 1 then CO_unknown_prelim2_10 = 1;
if CO_fire10 = 1 and CO_nonfire10 = 1 then CO_unknown_prelim3_10 = 1;
if CO_unknown_prelim2_10 = 1 or CO_unknown_prelim3_10 = 1 then CO_unknown10 = 1;
* sub-step f;
if CO_fire10 = 1 then Cause = 1;*fire related ;
if CO_nonfire10 = 1 then Cause = 2;*not fire related;
if CO_unknown10 = 1 then Cause = 3;*Unknown mechanism or intent;
if CO_fire10 = 1 and CO_nonfire10 = 1 then Cause = 3;
if CO_fire10 = 1 and CO_unknown10 = 1 then Cause = 3;
if CO_nonfire10 = 1 and CO_unknown10 = 1 then Cause = 3;
HealthOutcomeID=3;
MonthlyHosp=0;
run;
Read my post again. You can see that I first run the transpose after which the simplified check can be done in the following step.
Add additional variables to the RETAIN and the initialization at first.vhikey, and add your conditional assignments.
Any calculations depending on those variables have to be done after the subsetting IF.
Hello someone,
I am still having issues with this code and on step c. In this step, I need to flag unintentional non-fire-related incidents with records from steps A and B that have any discharge diagnosis code between X00 and X08. I get zero when I know I should see three incidents.
array DXS[18] $ dx1-dx18;
COyes_step2a10 = 0;
COno_step2b10 = 0;
CO_fire10 = 0;
CO_nonfire_prelim10 = 0;
CO_unknown_prelim1_10 = 0;
do z= 1 to 18;
* sub-step A;
if substr(DXS {z},1,5) IN:('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or
substr(DXS {z},1,6) IN: ('T582X1', 'T582X4', 'T588X1', 'T588X4')
then COyes_step2a10 = 1;
* sub-step B;
if substr(DXS {z}, 1,5)IN: ('T5802', 'T5803', 'T5812', 'T5813', 'T5892', 'T5893') or
substr(DXS {z},1,6) IN: ('T582X2', 'T582X3', 'T588X2', 'T588X3')
then COno_step2b10 = 1;
if COyes_step2a10 = 1 and COno_step2b10 NE 1 then COpoisoning = 1 ;
*differentiate causes: sub-steps C, D, E, F;
* sub-step c;
if substr(DXS {z}, 1,3)IN:('X00', 'X01', 'X02', 'X03', 'X04', 'X05', 'X06', 'X08')
then CO_fire10 = 1;
* sub-step d;
if substr(DXS {z},1,5) in ('T5801', 'T5811', 'T5891') or
substr(DXS {z},1,6) in ('T582X1', 'T588X1')
then CO_nonfire_prelim10 = 1;
if CO_fire10 NE 1 and CO_nonfire_prelim10 = 1 then CO_nonfire10 = 1;
* sub-step e;
if substr(DXS {z},1,5) IN: ('T5804', 'T5814', 'T5894') or
substr(DXS {z},1,6) IN: ('T582X4', 'T588X4')
then CO_unknown_prelim1_10 = 1;
if CO_fire10 ~= 1 and CO_unknown_prelim1_10 = 1 then CO_unknown_prelim2_10 = 1;
if CO_fire10 = 1 and CO_nonfire10 = 1 then CO_unknown_prelim3_10 = 1;
if CO_unknown_prelim2_10 = 1 or CO_unknown_prelim3_10 = 1 then CO_unknown10 = 1;
* sub-step f;
if CO_fire10 = 1 then Cause = 1;*fire related ;
if CO_nonfire10 = 1 then Cause = 2;*not fire related;
if CO_unknown10 = 1 then Cause = 3;*Unknown mechanism or intent;
if CO_fire10 = 1 and CO_nonfire10 = 1 then Cause = 3;
if CO_fire10 = 1 and CO_unknown10 = 1 then Cause = 3;
if CO_nonfire10 = 1 and CO_unknown10 = 1 then Cause = 3;
Example data. In the form of a working data step. Include some that "work" and the values that don't work.
Really hard to debug complex or lengthy logic without data.
Which steps have you verified that were working for the problem values?
Which are problem values? Which variables?
Is there any code that modifies the values of any of these variables that you not showing?
@Fadams12 wrote:
Hello someone,
I am still having issues with this code and on step c. In this step, I need to flag unintentional non-fire-related incidents with records from steps A and B that have any discharge diagnosis code between X00 and X08. I get zero when I know I should see three incidents.
array DXS[18] $ dx1-dx18; COyes_step2a10 = 0; COno_step2b10 = 0; CO_fire10 = 0; CO_nonfire_prelim10 = 0; CO_unknown_prelim1_10 = 0; do z= 1 to 18; * sub-step A; if substr(DXS {z},1,5) IN:('T5801', 'T5804', 'T5811', 'T5814', 'T5891', 'T5894') or substr(DXS {z},1,6) IN: ('T582X1', 'T582X4', 'T588X1', 'T588X4') then COyes_step2a10 = 1; * sub-step B; if substr(DXS {z}, 1,5)IN: ('T5802', 'T5803', 'T5812', 'T5813', 'T5892', 'T5893') or substr(DXS {z},1,6) IN: ('T582X2', 'T582X3', 'T588X2', 'T588X3') then COno_step2b10 = 1; if COyes_step2a10 = 1 and COno_step2b10 NE 1 then COpoisoning = 1 ; *differentiate causes: sub-steps C, D, E, F; * sub-step c; if substr(DXS {z}, 1,3)IN:('X00', 'X01', 'X02', 'X03', 'X04', 'X05', 'X06', 'X08') then CO_fire10 = 1; * sub-step d; if substr(DXS {z},1,5) in ('T5801', 'T5811', 'T5891') or substr(DXS {z},1,6) in ('T582X1', 'T588X1') then CO_nonfire_prelim10 = 1; if CO_fire10 NE 1 and CO_nonfire_prelim10 = 1 then CO_nonfire10 = 1; * sub-step e; if substr(DXS {z},1,5) IN: ('T5804', 'T5814', 'T5894') or substr(DXS {z},1,6) IN: ('T582X4', 'T588X4') then CO_unknown_prelim1_10 = 1; if CO_fire10 ~= 1 and CO_unknown_prelim1_10 = 1 then CO_unknown_prelim2_10 = 1; if CO_fire10 = 1 and CO_nonfire10 = 1 then CO_unknown_prelim3_10 = 1; if CO_unknown_prelim2_10 = 1 or CO_unknown_prelim3_10 = 1 then CO_unknown10 = 1; * sub-step f; if CO_fire10 = 1 then Cause = 1;*fire related ; if CO_nonfire10 = 1 then Cause = 2;*not fire related; if CO_unknown10 = 1 then Cause = 3;*Unknown mechanism or intent; if CO_fire10 = 1 and CO_nonfire10 = 1 then Cause = 3; if CO_fire10 = 1 and CO_unknown10 = 1 then Cause = 3; if CO_nonfire10 = 1 and CO_unknown10 = 1 then Cause = 3;
When I run the data step, the output I get is shown below. Line five should have been flagged as 1 in the column CO_fire10 instead of zero based on this code logic. The code other code that modifies the problem variable is proc SQL. See below.
proc sql ;
create table rr as
select distinct AdmissionMonth
,AgeGroup
, County
, Ethnicity
, Race
, HealthOutcomeID
, MonthlyHosp
, Sex
, YearAdmitted
, sum((Cause=1)) as IncidentCountFire
, sum((Cause=2)) as IncidentCountNonFire
, sum((Cause=3)) as IncidentCountUnknown
DX1 | DX2 | DX3 | DX4 | DX5 | DX6 | DX7 | DX8 | DX9 | DX10 | DX11 | DX12 | COyes_step2a10 | COno_step2b10 | CO_fire10 | CO_nonfire_prelim10 | CO_unknown_prelim1_10 | z | COpoisoning | CO_nonfire10 | CO_unknown_prelim2_10 | CO_unknown_prelim3_10 | CO_unknown10 |
T588X1A | I21A1 | I10 | E7800 | J920 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . | |||||||
T5891XA | E669 | Z6851 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . | |||||||||
T588X1A | G928 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . | ||||||||||
T588X1A | R569 | E782 | S0121XA | S0083XA | I10 | Z20822 | S90122A | S93401A | I2510 | Z951 | Z7982 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . |
T59811A | G931 | T588X1A | J682 | R1310 | K5900 | J0410 | B9689 | S06309A | F802 | Z781 | F0281 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . |
T59811A | J705 | J9691 | J9811 | E230 | E232 | I9589 | T486X5A | T588X1A | J680 | I959 | I10 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . |
T5891XA | M6282 | F29 | R945 | E559 | E611 | R319 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . | |||||
J441 | I5021 | J9601 | J9602 | N179 | F200 | F1910 | E874 | I248 | I471 | T5891XA | E875 | 1 | 0 | 0 | 1 | 0 | 19 | 1 | 1 | . | . | . |
Really need to post the CODE THAT ACTUALLY PRODUCES that output.
The "code" has an un-closed do statement starting with
do z= 1 to 18; * sub-step A;
Where is the closing END statement.
And tell us exactly why you think Cofire10 should be 1. Which values for which variable(s). Your code obviously isn't doing it so we can't tell what is wrong.\
As far as I can tell the only reason Cofire10 is assigned any value is the initial statements where you set a bunch of variables to 0. When i insert an END; where I think it makes sense and comment out those assignment of 0 values then Co_fire10 is missing. So nothing meets the code requirement to set it to one. None of the values on your step c list
if substr(DXS {z}, 1,3)IN:('X00', 'X01', 'X02', 'X03', 'X04', 'X05', 'X06', 'X08') then CO_fire10 = 1;
Appear on that "row 5". The 12 values you shared with us start with X much less any of X00 X01
T59811A G931 T588X1A J682 R1310 K5900 J0410 B9689 S06309A F802 Z781 F0281
So now tell use exactly which value on Row 5 was supposed to set Co_fire10 to 1.
I am starting to suspect too much cutting of code and not including all the needed bits.
If the Copoisoning code isn't needed for calculation Co_fire10 then remove it.
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.