BookmarkSubscribeRSS Feed
ballardw
Super User

@Fadams12 wrote:
Thank you for your feedback, looking at the data, I don't see X00 's and it is my first time working with this data, apparently someone who worked with this data before was able to flag Co_fire10 =1.

With the code you have shared I would have to say they were doing one of 3 things:

1) Using additional code

2) Using different data

3) A manual step. You can open data set in view mode that allows editing by typing.

Or possibly all three...

Fadams12
Calcite | Level 5

Yes, I also use a different data step in addition to the first one. see below. 

Data CO_Hosp(where=(COpoisoning=1));
Set 'C:\Users\hjt09632\Documents\SAS Dataset 2022\complete22.sas7bdat';

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 or 0 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;
END;
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; /*Step 6: Create according to data dictionary*/
	   MonthlyHosp = 0; /*Step 7: Create a variable called “MonthlyHosp” and set it to zero for all rows.*/ 

run;
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                                      
		                                                        
from  count_CO
group by AdmissionMonth
       , AgeGroup
       , County
       , Ethnicity
       , Race
       , HealthOutcomeID
	   , MonthlyHosp
       , Sex
       , YearAdmitted
;
quit;

data CO_Finalhosp;
	RETAIN RowIdentifier	AdmissionMonth	AgeGroup	County		Ethnicity	HealthOutcomeID	
		MonthlyHosp	Race	Sex	YearAdmitted;
set rr;
	RowIdentifier=_n_;
	KEEP RowIdentifier	AdmissionMonth	AgeGroup	County		Ethnicity	HealthOutcomeID	
		MonthlyHosp	Race	Sex	YearAdmitted IncidentCountFire	IncidentCountNonFire	
		IncidentCountUnknown  ;
		run;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 46 replies
  • 4270 views
  • 10 likes
  • 8 in conversation