Hi, My data is currently organized as:
| NAME | COLOR | PROFILE | HEIGHT |
| 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 |
I would like it to look like:
| NAME | PROFILE | RED | WHITE | BLACK | BLUE |
| K2000 | C | 5.10 | |||
| K2001 | B | 7.11 | 5.12 | 5.2 | |
| K2002 | A | 8.2 | 9.3 | ||
| K2006 | D | 5.5 | |||
| K2007 | A | 8.6 | 5.7 | ||
| K2009 | D | 8.8 | |||
| K2010 | B | 5.9 | |||
| K2011 | B | 9.6 | |||
| K2012 | C | 7.7 | 7.5 | 8.9 | 9.6 |
Regards,
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.
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.
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/...
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.
Ready to level-up your skills? Choose your own adventure.