BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a dataset that contains a character/string variable (var1).

Is there a way to get the counts (in proc freq) to produce another variable in a new dataset?

For example, the original dataset:

var1
a
a
b
c
c
c

proc freq produces output like this:

var1 frequency
a 2
b 1
c 3

I would like to take the frequency and divide it by another number (ie, 10) to get another variable so that my new dataset looks like this:

var1 frequency new_var
a 2 0.2
b 1 0.1
c 3 0.3

Any help would be appreciated!
2 REPLIES 2
P_J
Calcite | Level 5 P_J
Calcite | Level 5
Please try below;

data a;
input var1 $;
cards;
a
a
b
c
c
c
;
run;

proc sql;
create table b as
select distinct var1, count(var1) as freq, divide(calculated freq,10) as ave
from a
group by var1;
quit;
deleted_user
Not applicable
Works wonderfully! Thank you for your help.

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1513 views
  • 0 likes
  • 2 in conversation