BookmarkSubscribeRSS Feed
jwill731
Fluorite | Level 6

Hi Everyone,

 

I'm have a text file with date of birth entered in the format of mm/yyyy in numbers. So for example 5/1985.

 

When I try to tell sas to read the data with informat - DOB monyy6. it says invalid data for DOB. I'm guessing that it's because it's not a 3 letter representation of a month.

 

What would be the other informat because I tried mmyy6. and that doesn't exist.

 

Here's my code:

 

data temp;
	infile 'C:\Users\wjeon\Desktop\Masters\Data to William\PEI data/PEItxt.txt' delimiter='09'x dsd missover firstobs=2;
	length Patient_ID $20;
	informat Patient_ID $20. Gender 1. DOB mmyy10. Postal_Code $3. Region 1. Date_of_Service mmddyy10. Facility_type_id 2. ICD_9 $4. Specialty 3. Paid_amt best32. Approved_amt best32. Fee_Code $4.;
	input Patient_ID Gender DOB Postal_Code Region Date_of_Service Facility_type_id ICD_9 Specialty Paid_amt Approved_amt Fee_Code;
run;

I also tried to make it read it as characters so that i can try to convert it later on but it still says invalid

 

Thank you in advance.

3 REPLIES 3
mohamed_zaki
Barite | Level 11
data test;
input DOB $ ;
dt = input('01/'!!DOB,ddmmyy10.);
format dt mmyys. ;
datalines;
3/2011
;
run;
Reeza
Super User

Use the ANYDTDTE. informat.

 

data want;
informat dob anydtdte.;
format dob date9.;
input dob;
cards;
1/2016
5/2011
12/2010
;
run;
Peter_C
Rhodochrosite | Level 12
Let SAS do the informat searching for you!
See the paper on the idea
VFORMAT Lets SAS® Do the Format Searching
http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf
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
  • 3 replies
  • 1719 views
  • 2 likes
  • 4 in conversation