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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

1 REPLY 1
ballardw
Super User

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.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 1 reply
  • 884 views
  • 0 likes
  • 2 in conversation