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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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