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

Hi, could you please help me with this?

i should Create macro variable that will be used to filter the dataset BASEBALL to keep observation where player’s Surname isn’t starting with “W” letter.

Create a macro program to count how many players are playing –

 

  1. in the same DIV and in the same TEAM,
  2. in the same LEAGUE and at the same POSITION.
1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11
%let whereCond=%str(where name^=:'W');
DATA test;
   set sashelp.baseball;
   &whereCond.;
RUN;

%MACRO countPlayers(inputDS=,var1=,var2=);
   proc freq data=&inputDS.;
   table &var1.*&var2. /norow nocol nopercent;
   run;
%MEND countPlayers;

%countPlayers(inputDS=test,var1=div,var2=team);
%countPlayers(inputDS=test,var1=league,var2=position);
________________________

- Cheers -

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

What have you tried so far?

kindbe17
Fluorite | Level 6

 

I start with this code and stopped because i don't know what to do, could you please help me?

 

data base;
set sashelp.baseball;
run;

%let name=basename;
data &name.123;
base=3;
run;

Oligolas
Barite | Level 11
%let whereCond=%str(where name^=:'W');
DATA test;
   set sashelp.baseball;
   &whereCond.;
RUN;

%MACRO countPlayers(inputDS=,var1=,var2=);
   proc freq data=&inputDS.;
   table &var1.*&var2. /norow nocol nopercent;
   run;
%MEND countPlayers;

%countPlayers(inputDS=test,var1=div,var2=team);
%countPlayers(inputDS=test,var1=league,var2=position);
________________________

- Cheers -

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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