BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jordenlam
Calcite | Level 5

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,

ClassStudentPhyChePhyChePhyChe
A19595    
A2  8590  
A3    8080
B18886    
B2  95100  

 

And what I want is,

ClassStudentPhyChe
A19595
A28590
A38080
B18886
B295100

 

I guess first of all, we need to deal with the same-name column issue.

 

Thanks again for any suggestion!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

 

View solution in original post

5 REPLIES 5
jordenlam
Calcite | Level 5

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		
novinosrin
Tourmaline | Level 20

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;

 

ChrisNZ
Tourmaline | Level 20

Did you transpose the e and s in qusetion ?  🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1192 views
  • 1 like
  • 4 in conversation