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?
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.
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.