BookmarkSubscribeRSS Feed
Yoosf
Calcite | Level 5

Hello everyone,
I need assistance with counting rows in a SAS Viya table based on a specific value in another column. I have a table with two columns: category_column and value_column. I want to determine the number of rows that belong to each category in category_column.
For example, if I have the following table:

category_column value_column
A 10
B 20
A 30
C 40
B 50


I want to obtain the following results:

 

category_column count
A 2
B 2
C 1
I have tried using the PROC FREQ procedure, but it displays the results in a table, and I need to output the results as a dataset or table that I can use in subsequent steps.

Could someone suggest an efficient method to achieve this in SAS Viya?

Additional Information:

SAS Viya version: i dont know
I do not have access to SAS Studio.
Thank you very much for your help."

4 REPLIES 4
Ksharp
Super User
proc freq data=sashelp.class noprint;
table sex/out=want;
run;
Yoosf
Calcite | Level 5

I do not have access to SAS Studio.

Patrick
Opal | Level 21

@Yoosf wrote:

I do not have access to SAS Studio.


Just run it the way you're running any other SAS code. What client are you using? Or is this about creating a report in Visual Analytics?

Ksharp
Super User
"I have tried using the PROC FREQ procedure, "
Since you have already run PROC FREQ before, run my code as you did before.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Discussion stats
  • 4 replies
  • 888 views
  • 1 like
  • 3 in conversation