How do I create a variable "AGE" when using an external SAS data set via infile statement? The data set already has DOB in it.
This is how far I've gotten...
libname HW3 'c:\users\christopher\desktop\HW3';
data HW3.HW3_F18;
label ID = "Subjects ID"
RACE = "Subjects Race"
DOB = "Subjects Date of Birth"
FEV = "Subjects Fev"
HEIGHT = "Subjects Height"
GENDER = "Subjects Gender"
WEIGHT = "Subjects Weight"
DURATION = "Subjects Duration"
WBCCOUNT = "Subjects WBCCount"
MARITAL = "Subjects Marital Status"
EDUCATION = "Subjects Education";
infile 'c:\users\christopher\desktop\HW3\hw3_f18.dat';
input ID Race $ DOB mmddyy10. FEV Height Gender $ Weight Duration WBCCOUNT Marital $ Education $20.;
run;
proc print data= HW3.HW3_F18;
run;
How do I create a variable "AGE" when using an external SAS data set via infile statement? The data set already has DOB in it.
It's not any different than if you were doing it with a SAS data set, is there some specific reason you think there is?
You can add the computation after the INPUT statement.
Let's not forget the fourth argument when calling intck to get the right result
age = intck('year', dob, today(), "CONTINUOUS");
"external SAS data set" is an oxymoron.
It's either a SAS dataset, which is considered (in SAS speak) "internal", or an external file, which is not a SAS dataset. It is data, but it is not a dataset.
"SAS dataset" denotes a file with the extension .sas7bdat (in earlier days .ssd01 or .sd1) which resides in a directory for which you have a libname assigned.
Since, in your case, the library points to the same location where the external file resides, then after the data step you will have two files in c:\users\christopher\desktop\HW3:
the first is the external file, the second is the SAS dataset.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.