SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
richart
Fluorite | Level 6

not sure why I'm having so much trouble with this. I'm trying to create a sum column based on a output _freq_ column from proc summary. I ultimately want to make a percent from the freqs like so, where var, _TYPE_ and _FREQ_ are from my output out statement:

 

var_TYPE__FREQ_wantwant2
a1101380.072464
b1231380.166667
c1211380.152174
d1341380.246377
e1501380.362319
f101380

 

 

I can't get want and want2.

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi @richart  It appears you wanna group by _type_

 

proc sql;
create table want as
select * ,sum(_freq_) as want, _freq_/calculated want as want2  format=8.2
from have
group by _type_
order by _type_ ,var;
quit;
 
PaigeMiller
Diamond | Level 26

Since VAR is character, this is a very simple job for PROC FREQ.

 

proc freq data=have;
    tables var/noprint out=counts;
run;

If you really want a column called WANT with 138 on every row, this would require another step. But PROC FREQ gives the count for each level of VAR and the percent.

 

 

 
 
--
Paige Miller

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!

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
  • 968 views
  • 0 likes
  • 3 in conversation