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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 805 views
  • 0 likes
  • 2 in conversation