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!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.