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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.