BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello:

 

I am having a problem to input the text file,  the sample data is shown below.   

 

id,site,provider,hospital,scr,abi,dein,caseid,date,dob,admitdate,admittime,years,months,days,insurance,sex,race1,race2,race3,race4,race5,race6,hisp,zipcode,county,symptom1,scrsymptom2,scrsymptom3,scrsymptom4,scrsymptom5,scrsymptom6,scrsymptom7,scrsymptom8,scrsymptom9,scrsymptom10,scrsymptom11,exclusion1,exclusion2,exclusion3,exclusion4,exclusion5,exclusion6,exclusion7,exclusion8,exclusion9,exclusion10,elig,consent1,consent2,consent,interview,complete
1,0,1,8,PMS,HK,SHM,WH3T87601,10/05/16,01/30/05,09/05/07,14:10:30,9,159,4562,1,6,5,,,,,,2,55661,Right,4,,,,,,,,,,,,,,,,,,,,,1,,,2,0,1
2,0,2,8,OLS,MLB,FCN,QF2B64352,2014-12-03,2014-12-03,2014-06-03, 09:53:45,3,25,506,1,1,8,,,,,,1,69456,Wrong,1,,,,,,,,,,,,,,,,,,,,,8,,,2,4,6

 

I found out when I created my codes below, it didn't work.  Starting with column "admitdate", the date is missing.   Please help.  Thanks.

 

data test;
	infile "Pathway/test.txt" dlm=',' dsd missover lrecl=47 firstobs=2;
     input
             id   $
site   
provider   
hospital   
scr   $
abi   $
dein   $
caseid   $
date   $
dob   $
admitdate   $
admittime   $
years   
months   
days   
insurance   
sex   
race1   
race2   
race3   
race4   
race5   
race6   
hisp   
zipcode   
county   $
symptom1   
scrsymptom2   
scrsymptom3   
scrsymptom4   
scrsymptom5   
scrsymptom6   
scrsymptom7   
scrsymptom8   
scrsymptom9   
scrsymptom10   
scrsymptom11   $
exclusion1   
exclusion2   
exclusion3   
exclusion4   
exclusion5   
exclusion6   
exclusion7   
exclusion8   
exclusion9   
exclusion10   $
elig   
consent1   $
consent2   $
consent   
interview   
complete;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This is way too small:

 

lrecl=47

 

It specifies the number of characters that SAS will read from each incoming line.  Pick a wide enough value, perhaps:

 

lrecl=300

View solution in original post

4 REPLIES 4
Astounding
PROC Star

This is way too small:

 

lrecl=47

 

It specifies the number of characters that SAS will read from each incoming line.  Pick a wide enough value, perhaps:

 

lrecl=300

ybz12003
Rhodochrosite | Level 12

Thanks, it works.

ballardw
Super User

I strongly suggest reading Date values with a DATE informat and Times with a time informat. You can do a lot more with actual SAS Date and time values than character. Almost anything, including sorting, with character values as you show will require conversion to a date or headaches with multiple additional steps to get the values you want.

I suggest reading those dates with MMDDYY8. informat and the time with time8.

Assign an appropriate display format for people to use.

ybz12003
Rhodochrosite | Level 12

Thanks, but date9. won't work on 2014-03-06.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 971 views
  • 0 likes
  • 3 in conversation