BookmarkSubscribeRSS Feed
MichaelM
Calcite | Level 5
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!
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
MichaelM
Calcite | Level 5
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.
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 754 views
  • 0 likes
  • 3 in conversation