BookmarkSubscribeRSS Feed
Swapnas
Calcite | Level 5

hello,

 

I have learnt about TRUNCOVER option and worked with the below code without providing the option in INFILE statement

 

data sample;
length no $5.;
input no $;
datalines;
1
22
333
4444
55555
;
run;

 

i am expecting data like below for the variable "No" as i have not provided TRUNCOVER option in INFILE satatement

22

4444

55555

 

But to my surprise i am seeing data like this

1

22

333

4444

55555

 

I am not sure how this is working without providing TRUNCOVER option in the code

 

Please help me in understanding this

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Truncover is not used anywhere in your post??

This code:

data sample;
length no $5.;
input no $;
datalines;
1
22
333
4444
55555
;
run;

Is basically saying, read a string from the datalines up until the first space (unless you change the delimiter) and put that in no before moving the pointer on.  As there is one string per line you get one per output observations.  Exactly as you have coded it, no truncover used anywhere?

 

Maybe this paper will help you:

http://www2.sas.com/proceedings/sugi26/p009-26.pdf

Kurt_Bremser
Super User

One aspect of datalines is automatic padding to 80 characters. Any line in a datalines block that has less than 80 characters is automatically extended. So truncover is only needed with datalines if you want to read more than 80 characters, or you work with delimited data and have possible empty fields at the end of a line.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 681 views
  • 0 likes
  • 3 in conversation