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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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