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;

 

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
  • 919 views
  • 0 likes
  • 2 in conversation