BookmarkSubscribeRSS Feed
bat069
Calcite | Level 5


Hi all. I am new to SAS and am currently struggling with importing data. I am trying to import a raw data file that is set out in column format (ie no delimiters). There are 49 variables and approximately 1 million observations.

Here is a copy of my code (with most variables not shown):

data test;

     infile 'C:\datafile';

     input episode 1-12

               umrn $ 13-21

               gender 22-26

               ..........

               discharge_diag $ 252-501 (this is variable 29)

               pro $ 502-521

               .........

               sla06 $ 1186-1194; (variable 49)

run;

The problem I am having starts at variable number 29 which is 250 characters long, and in the vast majority of cases, is empty. When I import, for some reason when it gets to variable 29 it drops to the next observation and every variable after that (30-49) also starts on a new observation. I tried 'missover' at the end of the infile line but this just caused variable 29 - 49 to be empty.

Any help would be greatly appreciated.

Brian

Perth Australia

3 REPLIES 3
Kurt_Bremser
Super User

Use the "truncover" option when you have variable length records. This will cause the last variable(s) to be filled with what's available.

bat069
Calcite | Level 5

Hi Kurt,

Truncover has the same effect as missover...all the data from variable 29-49 just disappears.

Any other ideas?

Brian

Kurt_Bremser
Super User

a) could you please post an example of the input data?

b) could it be that you have linefeeds or CR/LF in the text data (the $250 field)? That would cause a new (short) line, and since you read with position, every variable whose pointer lies beyond the EOL is set to missing

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 869 views
  • 0 likes
  • 2 in conversation