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
Opal | Level 21

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
Opal | Level 21

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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