Thursday, April 3, 2008

PROC FORMAT

DATA HW1;
INFILE "D:\temp\files\hw1.txt"
DELIMITER=' ' /* or DLM=' '*/
MISSOVER
DSD
/* DSD means Delimiter-Sensitive Data, which does three things for you
First, it ignores delimiters in data values enclosed in quotation marks
Second, it does not read quotation marks as part of the data value
Third, it treats two delimiters in a row as a missing value.
DSD option assumes that delimiter is a comma. If your delimiter is not a comma then
you can use DELIMITER= option with the DSD option to specify the delimiter
*/
;
INPUT
SampleID
CaseControl $
Gender $
Race $
Age
NoCig
Multivitamins
Calcium
TumorICD9 $
FamilyHistory $
HRT $
Height
Weight;
BMI = (Weight*0.45)/((Height*0.0254)**2);
Proc format;
value Mul 1='never' 2='former' 3='current';
value Cal 1='never' 2='former' 3='current';
RUN;

proc print data = hw1 LABEL;
TITLE1 "CS133/BIOT133 - Introduction to SAS Programming";
TITLE2 "Homework #1";
LABEL
SampleID = "Sample ID"
CaseControl = "Case/Control"
Gender = "Gender"
Race = "Race"
Age = "Age"
NoCig = "Number of cigarettes smoked/day"
Multivitamins = "Multivitamins taken"
Calcium = "Calcium supplements taken"
TumorICD9 = "Tumor site by ICD9 code"
FamilyHistory = "Family History"
HRT = "HRT use"
Height = "Height in inches"
Weight = "Weight in pounds"
;
FORMAT Multivitamins Mul. Calcium Cal. BMI 2. ;
FOOTNOTE1 "Student - Yuan-Kai Huang";
FOOTNOTE2 "April 2, 2008";
run;

No comments: