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 ?  🙂

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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