Hello,
I have the code
data name;
input name $32.;
datalines;
a
b
c
;run;
I want to make it as below to save space.
how can I tell SAS to take space as a break?
data name;
input name $32.;
datalines;
a b c d e f ....
;
Thank you,
HHC
Read about the double trailling @ in the doc about the input statement
data name;
input name :$32. @@;
datalines;
a b c d e f
;
proc print; run;
Consider that you have a dataset name with variable name and id with common value and you want to derive namec as mentioned. Then please try the below code. Also for this you need a dummy variable id with common values across all records so that we could use the first. logic.
you could create a dummy id variable and try the below logic and it will work
data name;
input name :$32. id;
datalines;
a 1
b 1
c 1
d 1
e 1
f 1
g 1
h 1
;run;
data namewant;
length namec $32;
set name;
by id notsorted;
retain namec;
if first.id then namec=name ;
else namec=catx(' ',namec,name);
if last.id;
run;
Read about the double trailling @ in the doc about the input statement
data name;
input name :$32. @@;
datalines;
a b c d e f
;
proc print; run;
Am not sure what you mean really: "I want to make it as below to save space.". What you are doing is taking normalised data, transposing and concatenting that data into one observation. If you wanted to save "space" - i.e. storage space then you can save yourself the difficulty and just set:
input name $32.;
To:
input name $1.;
Transposing the data may make accessing that data far harder than it currently is (and you may hit limitations on string size and such like). Maye a good example to show test data which really illustrates your problem, and why you are doing it?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.