Hello,
I'm hoping someone could help me with the following.
I have the following output table and would like the data to be in one row instead of multiple rows.
A | B | C | D | E |
28846512 | . | . | . | . |
. | 10942982 | . | . | . |
. | . | 1418164 | . | . |
. | . | . | 207.29 | . |
. | . | . | . | 20092412 |
I want the above table to look like below:
A | B | C | D | E |
28846512 | 10942982 | 1418164 | 207.29 | 20092412 |
Value your help.
Kind regards,
Mags
proc means data=have noprint;
var _all_;
output out=want(drop=_: ) max=;
run;
What type of input you have ? is it a sas dataset or external file (like: .txt or .xsl) ?
Is there an ID column ? How many variables are in a row ?
What do you want to do with the data ?
Why not save it all in one column ?
The solution depends on your answers.
Assuming there are 5 columns:
data want;
set have;
retain v1-v5;
array vx v1-v5;
array inp a b c d e;
i = mod(_N_, 5);
vx(i) - inp(i);
if i=0 then output;
keep v1-v5;
run;
Thanks kindly Shmuel.
proc means data=have noprint;
var _all_;
output out=want(drop=_: ) max=;
run;
Thank you so much PG. It works perfectly.
Beautiful solution!
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.