The INPUT is
INPUT
#1 IDNUM 1-4 AGE 5-8 SEX 13-15 SURVIVE 16 SHOKTYPE 17-20 SBP1 21-24
MAP1 25-28 HEART1 29-32 CARDIAC1 45-48 2 URINE1 57-60 HGB1 69-72 1
#2 SBP2 21-24 MAP2 25-28 HEART2 29-32 CARDIAC2 45-48 2 URINE2 57-60 HGB2 69-72 1;
*First always run a descriptive stat to ensure there are no missing values, there were no missing values for this dataset;
PROC FORMAT; *Recommended to include PROC FORMAT in the very beginning of the code;
VALUE SEXFMT 1= "Male"
2= "Female";
VALUE SHOCKFMT 2= "Non-Shock"
3= "Hypovolemic Shock"
4= "Cardiogenic Shock"
5= "Bacterial Shock"
6= "Neurogenic Shock"
7= "Other"; *CHANGE??;
VALUE DIEDFMT 1= "Lived"
3="Died";
VALUE AGECATFMT 1="<45"
2 = "45-55"
3 = "56-65"
4 = ">65";
RUN;
DATA AFIFI;
INFILE '/home/u63916728/My Sas File/Class Raw Data Files sasuser.v94/AFIFI-2.DAT';
INPUT
#1 IDNUM 1-4 AGE 5-8 SEX 13-15 SURVIVE 16 SHOKTYPE 17-20 SBP1 21-24
MAP1 25-28 HEART1 29-32 CARDIAC1 45-48 2 URINE1 57-60 HGB1 69-72 1
#2 SBP2 21-24 MAP2 25-28 HEART2 29-32 CARDIAC2 45-48 2 URINE2 57-60 HGB2 69-72 1;
LABEL
MAP1 = 'Mean Arterial Pressure 1 (mm Hg)'
HEART1 = 'Heartrate 1 (Beats Per Minute)'
CARDIAC1 = 'Cardiac Index 1'
MAP2 = 'Mean Arterial Pressure 2 (mm Hg)'
HEART2 = 'Heartrate 2 (Beats Per Minute)'
CARDIAC2 = 'Cardiac Index 2'; *End here;
*Label was created in the DATA Step;
*Now we will recode variables;
if shoktype <=0 and shoktype ne . then shock=0;
else if shoktype>=1 then shock=1;
if survive<=0 and survive ne . then died=0;
else if survive>0 then died=1;
IF AGE NE . AND AGE<45 THEN AGECAT=1;
ELSE IF 45<=AGE<56 THEN AGECAT=2;
ELSE IF 56<=AGE<66 THEN AGECAT =3;
ELSE IF AGE >=66 THEN AGECAT = 4; *MIGHT BE ABLE TO DO >65;
FORMAT SEX SEXFMT. SHOKTYPE SHOCKFMT. SURVIVE DIEDFMT. AGE AGECATFMT.;
RUN;
Below is what I have tried. Agecat is the only proper recoded variable.
I don't see any example input values for Shoktype, Survive as read by the input statement.
It does look like the format Shockfmt should be used with variable Shock not with Shoktype.
Similar the format Diedfmt looks like it should be with Died, not Survive.
FORMAT SEX SEXFMT. SHOKTYPE SHOCKFMT. SURVIVE DIEDFMT. AGE AGECATFMT.;
For 99 percent of the time I would not have recoded age at all, just define the format for age categories as
VALUE AGECATFMT 0 -<45 ="<45" 45-55 = "45-55" 56-65 = "56-65" 66-high = ">65";
Assuming age is integer values. Just use that as the format for the Age variable for any analysis, reporting or graphing. My permanent format libraries have about a dozen different age category formats that are used as needed on the age value. That way I don't have to keep recoding age into 4 (or 6 or 23 or 8 groups).
Wow. A data file with implied decimal points. I haven't seen one of those in over 35 years.
data test;
input CARDIAC2 1-4 2 ;
cards;
1234
567
;
Result
Obs CARDIAC2 1 12.34 2 5.67
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.