BookmarkSubscribeRSS Feed
krm
Obsidian | Level 7 krm
Obsidian | Level 7

Hi, 

 

I have the following data set.

 

 

data teams;
input
team $5. wins group $5.;
format
team $5.;
datalines;
TeamA 10 West
TeamA 15 West
TeamA 32 West
TeamB 2  West
TeamB 17 West
TeamB 5  West
;

 

 

I am using proc report to transpose the team names and grouping them by group. I am using the following code below. 

 

 

proc report nowd data=teams
style(header)=[background=white];
col (group (('Teams' team),(wins)));
	define group/   "Group";
	define team /  across style (header)=[background=lightblue] ' ' ; 
	define wins /  "Wins";
run;

 

 

When I run the code I get the following result below:

 

West10.
West15.
West32.
West.2
West.17
West.5

 

 

I am trying to figure out what I am missing here, I want to group both teams by group, so that the end result would look like below. 

 


West102
West1517
West325


Any help would be greatly appreciated!

Thanks!!

 

 

Edited:

 

I was able to figure it out later and wanted to keep to post for others if further reference is needed. 

 

Adding group in the line solves the problem 

 

proc report nowd data=teams
style(header)=[background=white];
col (group division (('Teams' team),(wins)));
	define group/ group  "Group";
	define division/ group  "Div";
	define team /  across style (header)=[background=lightblue] ' ' ; 
	define wins /  "Wins";
run;
3 REPLIES 3
Ksharp
Super User

You need to change data set.

 

data teams;
input team $5. wins group $5.;
format
team $5.;
datalines;
TeamA 10 West
TeamA 15 West
TeamA 32 West
TeamB 2  West
TeamB 17 West
TeamB 5  West
;
run;
data teams;
 set teams;
 by group team;
 if first.team then n=0;
 n+1;
run;
proc report nowd data=teams
style(header)=[background=white];
col group n ('Teams' team),wins;
	define group/group   "Group";
	define n/group noprint;
	define team /  across style (header)=[background=lightblue] ' ' ; 
	define wins /  "Wins";
run;
Babloo
Rhodochrosite | Level 12

Could you please tell me the purpose of folloing line in proc report?

 

col group n ('Teams' team),wins;
Ksharp
Super User

I made another group variable N to make it happen.

You will see N is how to generate in data step.

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
  • 3 replies
  • 1183 views
  • 1 like
  • 3 in conversation