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.
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;
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.
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.