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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.