BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lulu3
Obsidian | Level 7

Hi expert, I wanted split my text into several lines.  For example:

 

data want;
input x $ y $ z $;
datalines;
aa bb cc
;
run;

data want;
set want;
want=strip(x)||'/'||strip(y)||'/'||strip(z);
run;

it comes out : aa/bb/cc

 

but I want:

aa/

  bb/

    cc

line 2 has 2 leading space compared to line 1, line 3 has 4 leading space compared to line1.

 

Thanks a lot.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You would need to store line feeds (or carriage return/line feed) in your variable which is almost never a good idea.

If this is about printing your data to a file or creating a report then use a data step put or a procedure like Proc Report to create the layout you want.

data have;
  input x $ y $ z $;
  datalines;
aa bb cc
;

data _null_;
  file print;
  set have;
  put 
      @1 x +(-1) '/' 
    / @3 y +(-1) '/'
    / @5 z
    ;
run;

Patrick_0-1676074693104.png

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Where do you intend to use this? Depending on the type of document you may not get consistent behavior so you need to tell us what sort of file this output should be for.

Patrick
Opal | Level 21

You would need to store line feeds (or carriage return/line feed) in your variable which is almost never a good idea.

If this is about printing your data to a file or creating a report then use a data step put or a procedure like Proc Report to create the layout you want.

data have;
  input x $ y $ z $;
  datalines;
aa bb cc
;

data _null_;
  file print;
  set have;
  put 
      @1 x +(-1) '/' 
    / @3 y +(-1) '/'
    / @5 z
    ;
run;

Patrick_0-1676074693104.png

 

 

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