BookmarkSubscribeRSS Feed
ivethguzman
Calcite | Level 5

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 : 

 

Screen Shot 2019-11-13 at 8.40.26 PM.png

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

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;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 947 views
  • 0 likes
  • 2 in conversation