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

Hi, My data is currently organized as:

 

NAMECOLORPROFILEHEIGHT
K2000REDC 5.10 
K2001WHITEB 7.11 
K2001BLACKB 5.12 
K2001BLUEB 5.2 
K2002BLUEA 9.3 
K2002REDA 8.2 
K2006WHITED 5.5 
K2007WHITEA 8.6 
K2007BLUEA 5.7 
K2009WHITED 8.8 
K2010BLACKB 5.9 
K2011REDB 9.6 
K2012REDC 7.7 
K2012BLUEC 9.6 
K2012WHITEC 7.5 
K2012BLACKC 8.9 

 

I would like it to look like:

 

NAMEPROFILEREDWHITEBLACKBLUE
K2000C 5.10    
K2001B  7.11  5.12  5.2 
K2002A 8.2    9.3 
K2006D  5.5   
K2007A  8.6   5.7 
K2009D  8.8   
K2010B   5.9  
K2011B 9.6    
K2012C 7.7  7.5  8.9  9.6 

 

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Do you want a data set that will be used by other programs or a report that people will read?

 

For a report either Proc Tabulate or Report will do something similar:

data have;
 input name $ color $ Profile $ height;
datalines;
K2000 RED C  5.10  
K2001 WHITE B  7.11  
K2001 BLACK B  5.12  
K2001 BLUE B  5.2  
K2002 BLUE A  9.3  
K2002 RED A  8.2  
K2006 WHITE D  5.5  
K2007 WHITE A  8.6  
K2007 BLUE A  5.7  
K2009 WHITE D  8.8  
K2010 BLACK B  5.9  
K2011 RED B  9.6  
K2012 RED C  7.7  
K2012 BLUE C  9.6  
K2012 WHITE C  7.5  
K2012 BLACK C  8.9  
;

proc tabulate data=have;
  class name color profile;
  var height;
  table name='' * profile='',
        color=''*height=' '*max=' '
       /box= 'Name Profile' misstext=' '
  ;
run;
proc report data=have;
   column  name profile color,height;
   define name /group;
   define profile/group;
   define color/across ' ';
   define height/ ' ';
run;

Note use of a data step to provide example data and code box opened on the forum with the {I} icon to paste code.

View solution in original post

2 REPLIES 2
ballardw
Super User

Do you want a data set that will be used by other programs or a report that people will read?

 

For a report either Proc Tabulate or Report will do something similar:

data have;
 input name $ color $ Profile $ height;
datalines;
K2000 RED C  5.10  
K2001 WHITE B  7.11  
K2001 BLACK B  5.12  
K2001 BLUE B  5.2  
K2002 BLUE A  9.3  
K2002 RED A  8.2  
K2006 WHITE D  5.5  
K2007 WHITE A  8.6  
K2007 BLUE A  5.7  
K2009 WHITE D  8.8  
K2010 BLACK B  5.9  
K2011 RED B  9.6  
K2012 RED C  7.7  
K2012 BLUE C  9.6  
K2012 WHITE C  7.5  
K2012 BLACK C  8.9  
;

proc tabulate data=have;
  class name color profile;
  var height;
  table name='' * profile='',
        color=''*height=' '*max=' '
       /box= 'Name Profile' misstext=' '
  ;
run;
proc report data=have;
   column  name profile color,height;
   define name /group;
   define profile/group;
   define color/across ' ';
   define height/ ' ';
run;

Note use of a data step to provide example data and code box opened on the forum with the {I} icon to paste code.

PaigeMiller
Diamond | Level 26

It's not considered a good thing to post the same question twice.

 

I ask that everyone add their responses to the other thread on this question at https://communities.sas.com/t5/New-SAS-User/How-to-use-to-pivot-my-data-using-proc-tabulate-or-proc/...

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 304 views
  • 0 likes
  • 3 in conversation