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;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: