SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steelersgirl
Calcite | Level 5

I am looking at a data set about football players. After I read in the data set, I am trying to calculate the 5-number summary for the passYD variable for only players who position in qb. I want to do this separately for each value of team. This is the code I have been trying

 

DATA NFL;
FILENAME webpage URL 'http://people.stat.sc.edu/hitchcock/nfl_season_data.txt';
infile webpage DLM=',' DSD;
INPUT idcode $ lastname :$20. firstname :$20. year team $ position $ G GS COMP ATT
PassYD PassTD INT rush rushYD rushTD rec recYD recTD;
RUN;


PROC MEANS=PassYD;
WHERE position=qb;
BY team;
RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@Steelersgirl wrote:

I am looking at a data set about football players. After I read in the data set, I am trying to calculate the 5-number summary for the passYD variable for only players who position in qb. I want to do this separately for each value of team. This is the code I have been trying

 

DATA NFL;
FILENAME webpage URL 'http://people.stat.sc.edu/hitchcock/nfl_season_data.txt';
infile webpage DLM=',' DSD;
INPUT idcode $ lastname :$20. firstname :$20. year team $ position $ G GS COMP ATT
PassYD PassTD INT rush rushYD rushTD rec recYD recTD;
RUN;


PROC MEANS=PassYD;
WHERE position=qb;
BY team;
RUN;

You can specify the statistics desired in the PROC MEANS statement. 

You'll also likely want to capture the output into a data set. 

 

PROC MEANS DATA=NFL N Mean MEdian MIN MAX STD; *list statistics here;

WHERE position='qb'; *note that this is case sensitive;

BY team;

var varName; *list your variable to analyze here ;

ods output summary = want; *store results;
RUN;

Hope that helps.

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

What results does the code give?

qd is not a variable is it? it's a value so must be quoted.

Reeza
Super User

@Steelersgirl wrote:

I am looking at a data set about football players. After I read in the data set, I am trying to calculate the 5-number summary for the passYD variable for only players who position in qb. I want to do this separately for each value of team. This is the code I have been trying

 

DATA NFL;
FILENAME webpage URL 'http://people.stat.sc.edu/hitchcock/nfl_season_data.txt';
infile webpage DLM=',' DSD;
INPUT idcode $ lastname :$20. firstname :$20. year team $ position $ G GS COMP ATT
PassYD PassTD INT rush rushYD rushTD rec recYD recTD;
RUN;


PROC MEANS=PassYD;
WHERE position=qb;
BY team;
RUN;

You can specify the statistics desired in the PROC MEANS statement. 

You'll also likely want to capture the output into a data set. 

 

PROC MEANS DATA=NFL N Mean MEdian MIN MAX STD; *list statistics here;

WHERE position='qb'; *note that this is case sensitive;

BY team;

var varName; *list your variable to analyze here ;

ods output summary = want; *store results;
RUN;

Hope that helps.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 7948 views
  • 0 likes
  • 3 in conversation