BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi guys

how to count cars makers list in sashelp.cars using proc report

8 REPLIES 8
andreas_lds
Jade | Level 19

What have you tried? Why proc report?

BrahmanandaRao
Lapis Lazuli | Level 10

count  no of car makers list

andreas_lds
Jade | Level 19

So you aren't limited to use proc report?

Kurt_Bremser
Super User

Show us what you tried, so we can point out where you went wrong.

I mean, you did try something, or do you expect that for all your life, others will do your work?

BrahmanandaRao
Lapis Lazuli | Level 10
data ds;
set sashelp.cars;

run;

proc sort data=ds;
by make;
run;


data ds2 (keep=make);
set ds;
by make;
if last.make then output;
run;

Hi Kurt_Bremser

I tried  but i am looking output in proc report 

Kurt_Bremser
Super User

Then read the documentation of PROC REPORT and start hacking away. You will learn a LOT doing that.

Hint: PROC REPORT provides a statistic (n) that has the count.

Also do a Google search for "sas counting in proc report".

 

PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:
data ds;
set sashelp.cars;

run;

proc sort data=ds;
by make;
run;


data ds2 (keep=make);
set ds;
by make;
if last.make then output;
run;

Hi Kurt_Bremser

I tried  but i am looking output in proc report 


Maxim 14 — Use the Right Tool

 

For tasks that are essentially counting, use PROC FREQ, no need to create new data sets and sort the new data sets. All you need is four lines of code (and the first line is really optional, you could leave it out):

 

ods select nlevels;
proc freq data=sashelp.cars nlevels;
    tables make;
run;

If you really really really need it from PROC REPORT, show us what the report should look like.

 

 

--
Paige Miller
Cynthia_sas
Diamond | Level 26

Hi:

  There are several procedures, including PROC FREQ, PROC TABULATE as well as PROC REPORT and PROC SQL that could generate counts for you. 3 of these procedures are shown below -- going from least lines of code to most lines of code:

Cynthia_sas_0-1645222720240.png

 

Cynthia

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
  • 8 replies
  • 1684 views
  • 1 like
  • 5 in conversation