BookmarkSubscribeRSS Feed
ravi999985
Calcite | Level 5

data my;
input details $ 1-100;
cards;
I am                       John.
I studied from      MM University
I have             done MBA
;
run;

 

I need the ouput as below. but it is not reading the data properly.

 

details

------------

I am                       John.
I studied from      MM University
I have             done MBA

2 REPLIES 2
Ksharp
Super User
data my;
infile cards truncover;
input details $ 1-100;
cards;
I am                       John.
I studied from      MM University
I have             done MBA
;
run;

Tom
Super User Tom
Super User

Pay attention to what SAS tells you in the SAS log.

 

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.MY has 1 observations and 1 variables.

Since in-line data is padded to the next multiple of 80 bytes trying to read 100 bytes from a line that only has 80 bytes is what is causing SAS to move to a new line to try and find enough data.

 

 

You can prevent that by adding an INFILE statement so you can add the TRUNCOVER option.

 

data my;
  infile cards truncover;
  input details $ 1-100;
cards;
I am                       John.
I studied from      MM University
I have             done MBA
;

Result

 

 

Obs                 details

 1     I am                       John.
 2     I studied from      MM University
 3     I have             done MBA

Note that this is a good example of why you almost never want to use the ancient MISSOVER option.  

 

 

Try it with MISSOVER instead of TRUNCOVER.

 

Spoiler
data my;
  infile cards missover;
  input details $ 1-100;
cards;
I am                       John.
I studied from      MM University
I have             done MBA
;

proc print;
run;

 

Obs    details

 1
 2
 3

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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