Hi,
I think it can be solved by using proc transpose but not sure. Any ideas are welcome. Many thanks!
Now I have from CSV,
| Class | Student | Phy | Che | Phy | Che | Phy | Che |
| A | 1 | 95 | 95 | ||||
| A | 2 | 85 | 90 | ||||
| A | 3 | 80 | 80 | ||||
| B | 1 | 88 | 86 | ||||
| B | 2 | 95 | 100 |
And what I want is,
| Class | Student | Phy | Che |
| A | 1 | 95 | 95 |
| A | 2 | 85 | 90 |
| A | 3 | 80 | 80 |
| B | 1 | 88 | 86 |
| B | 2 | 95 | 100 |
I guess first of all, we need to deal with the same-name column issue.
Thanks again for any suggestion!
HI @jordenlam Plz try replicating this
data extract;
infile 'your_file' dsd truncover;
input Class $ student @;
do _n_=1 to 3;
input phy che @ ;
if not missing(phy) and not missing(che) then output;
end;
run;
The loop can also be written as
do until(not missing(phy) and not missing(che)) ;
input phy che @ ;
if not missing(phy) and not missing(che) then output;
end;
This can be handled immediately when reading the csv file. Please post a few example lines of the csv file, using the {i} button.
Thanks!
This is the data from CSV,
Class Student Phy Che Phy Che Phy Che A 1 95 95 A 2 85 90 A 3 80 80 B 1 88 86 B 2 95 100
HI @jordenlam Plz try replicating this
data extract;
infile 'your_file' dsd truncover;
input Class $ student @;
do _n_=1 to 3;
input phy che @ ;
if not missing(phy) and not missing(che) then output;
end;
run;
The loop can also be written as
do until(not missing(phy) and not missing(che)) ;
input phy che @ ;
if not missing(phy) and not missing(che) then output;
end;
There's no delimiter in there, so it's not a csv file.
Did you transpose the e and s in qusetion ? 🙂
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.