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-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!

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