DATA Step, Macro, Functions and more

Transposing after proc compare with duplicates

Accepted Solution Solved
Reply
Senior User
Posts: 1
Accepted Solution

Transposing after proc compare with duplicates

Hello,

I am trying to transpose data after the proc compare.

Here is what the data currently looks like after the proc compare:

fullname_type_cubemdx_condition
Testuser1BASEUG_ApplicantsXYZ
Testuser1BASEUG_DegreesXYZ
Testuser1BASEUG_EnrollmentXYZ
Testuser1BASEGR_ApplicantsXYZ
Testuser1BASEGR_DegreesXYZ
Testuser1BASEGR_EnrollmentXYZ
Testuser2COMPAREWaitlist_Student_Dataabc
Testuser2COMPAREUG_Applicantsabc
Testuser2COMPAREUG_Degreesabc
Testuser2COMPAREUG_Enrollmentabc

 

Here is what I need the data to look like:

 fullname          Variable Name            BASE    COMPARE

Testuser1UG_Applicantsxyz 
Testuser1UG_Degreesxyz 
Testuser1UG_Enrollmentxyz 
Testuser1GR_Applicantsxyz 
Testuser1GR_Degreesxyz 
Testuser1GR_Enrollmentxyz 
Testuser2Waitlist_Student_Data abc
Testuser2UG_Applicants abc
Testuser2UG_Degrees abc
Testuser2UG_Enrollment abc

 

Any help would be great, thanks!


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 13,498

Re: Transposing after proc compare with duplicates

Posted in reply to SasPerson85

Can you show what you tried?

Is the exact order important? If so transpose may not be the best way.

 

Perhaps:

data want;
   set have;
   If _type_='BASE' then BASE=mdx_condition;
   else if _type_='COMPARE' then Compare=mdx_condition;
   drop _type_ mdx_condition;
run;

if you want to change the variable name from  cube to variable_name either use rename or add a label for cube.

 

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Posts: 13,498

Re: Transposing after proc compare with duplicates

Posted in reply to SasPerson85

Can you show what you tried?

Is the exact order important? If so transpose may not be the best way.

 

Perhaps:

data want;
   set have;
   If _type_='BASE' then BASE=mdx_condition;
   else if _type_='COMPARE' then Compare=mdx_condition;
   drop _type_ mdx_condition;
run;

if you want to change the variable name from  cube to variable_name either use rename or add a label for cube.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 62 views
  • 0 likes
  • 2 in conversation