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