BookmarkSubscribeRSS Feed
navinrraj
Calcite | Level 5

hi there!.

how to print entire content of particular character varible

for example i need to print like " my name is alphapet and place is world " on entire column

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

The length of a character variable is set the first time the data step meets the variable. Therefore, make sure that the length of the variable is large enough to meet your needs. 

 

As a small example, here:

 

data test1;
   string="abc";output;
   string=" my name is alphapet and place is world ";output;
run;

the length of String is three. Therefore the string you want to have in a variable is truncated. Instead, we can make sure the no truncation happens by setting a large enough length like this

 

data test2;
   length string $200;
   string="abc";output;
   string=" my name is alphapet and place is world ";output;
run;
navinrraj
Calcite | Level 5
Thanks and how to do it tat from infile methid
Kurt_Bremser
Super User

Post the code you already have, and we can show you where to improve it.

If you read from an external file, include an example for that.

See my footnotes for hints on posting code; use the {i} button to post lines from the external file.

navinrraj
Calcite | Level 5

data breakfast;

length items $20;

length description $85;

infile"/home/naveence0/food.txt" dlm='|';

input items$ price description$ calorieskl;

run;

proc print data = breakfast;

data breakfast;

set breakfast;output;

format price DOLLAR10.2;

;

run;

proc print data= breakfast;

Kurt_Bremser
Super User

You can simplify your code by using informats with a colon, and formatting price in the same step:

input items :$20. price description :$85. calorieskl;
format price dollar10.2;

The length statements can now be omitted.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1313 views
  • 0 likes
  • 3 in conversation