Help using Base SAS procedures

Import Function Format

Reply
Occasional Contributor
Posts: 5

Import Function Format

I have data with date of births that I am trying to import. Below is the code to import the date:

DATA BIRTHNEW;
INFILE B4 END=EOF7 LRECL=1000;
IF EOF7 THEN INFILE B5 END=EOF8 LRECL=1000;
IF EOF8 THEN INFILE B6 END=EOF9 LRECL=1000;
IF EOF9 THEN INFILE B7 END=EOF10 LRECL=1000;
IF EOF10 THEN INFILE B8 END=EOF11 LRECL=1000;
IF EOF11 THEN INFILE B9 END=EOF12 LRECL=1000;

INPUT CHILDDOB 55-62 HOSPITAL 73-76 MOMDOB 124-131;

This obviously imports it as a numeric variable, but I have tried:

INPUT CHILDDOB 55-62 Date8. HOSPITAL 73-76 MOMDOB 124-131 Date8.;

But they do not import into my dataset correctly. I have also tried just leaving the import as just a numeric variable and then changing the format from the ViewTable screen by double-clicking on the variable name and changing the Column Attributes, but I come across the problem that there are not leading zeros in my source data
6032004
2072005
11072007
so all of the dates are not of the same length. I'm trying to put into any date format so I can compare.

Thanks for your help!
Super Contributor
Super Contributor
Posts: 3,174

Re: Import Function Format

Just curious how you expect to interpret the string "112001" - is it 1/1/2001 or 11/20/01?

You will likely need to read-up the data into a SAS character type variable, scrub it -- split into individual month, day, year components and then use MDY function in an assignment statement.

Scott Barry
SBBWorks, Inc.
Occasional Contributor
Posts: 5

Re: Import Function Format

From looking at the data, I would assume (not the best idea) that 112001 is 1/1/2001 as all of the years are 4 digits long. Thanks for the advice, I'll give it a try.
SAS Super FREQ
Posts: 8,740

Re: Import Function Format

Hi:
As Scott pointed out, there's no need to post in multiple forums. I responded with an example here:
http://support.sas.com/forums/thread.jspa?threadID=11696&tstart=0

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 106 views
  • 0 likes
  • 3 in conversation