Hello,
I'm having trouble using infromat and input. I want my DOB to look like this "10/21/46", but I keep getting negative wrong numbers.
Does it have to do with the year that SAS was invented?
I have put my code below, with the text file and the output.
Thank you
SAS Code:
data Employ;
infile '/folders/myfolders/MY SAS Files/Data/EMPLOY.txt';
informat DOB MMDDYY8.;
input ID GENDER $ DOB @@;
label ID = 'Employee Number'
GENDER = 'Gender'
DOB = 'Date of Birth';
run;
/**
proc print;
run;
/**/
proc sort data=Employ out= empl;
by ID;
run;Text File:
01 F 10/21/46 02 F 09/02/44 03 M 04/23/55 04 F 11/11/38
Output :
The values are imported correctly. They are just not formatted yet. Simply add a format statement like this
data Employ;
infile datalines;
informat DOB MMDDYY8.;
format DOB MMDDYY8.;
input ID GENDER $ DOB @@;
label ID = 'Employee Number'
GENDER = 'Gender'
DOB = 'Date of Birth';
datalines;
01 F 10/21/46
02 F 09/02/44
03 M 04/23/55
04 F 11/11/38
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.