BookmarkSubscribeRSS Feed
JinboZhao
Calcite | Level 5

Hi SAS,

 

I have a dataset contains some character variables and other categorical variables but displaying with numbers. I would like to generate a table the following:

MARITAL_STATUS
MARITAL_STATUSFrequencyPercentCumulative
Frequency
Cumulative
Percent
C100.1100.1
D200.2300.3
M300.3600.6
O100.1700.7
S100.1800.8
W200.21001

 

I did this using PROC FREQ DATA= ; TABLES _CHARACTER_; RUN;

 

However, this is only works for thsoe variables which contain chararcter values. For those variables have numeric values, how could I get the similar result? I gave a sample table here as well.

Grade IndicatorFrequencyPercentCumulative
Frequency
Cumulative
Percent
1100.1100.1
2200.2300.3
3300.3600.6
4100.1700.7
5100.1800.8
6200.21001

 

Hope anybody can help me. Many appreciation. 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well the obvious answer here is to have character values for those variables which need to have frequency counts performed on them.  For instance in my CDISC standards would have:

Grade char(1)

GradeN num

 

That way you can do both freq and sums.

 

You could also format the numeric variables:

proc format;
  value gr
    1="1";
run;

proc freq...;
...
  format grade gr.;
run;
Astounding
PROC Star

PROC FREQ runs on numeric variables as well.  Just add any you want, as part of the TABLES statement.

 

And be a little bit careful.  If you add a numeric variable that is really continuous rather than categorical, you can generate an extremely long table.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1119 views
  • 0 likes
  • 3 in conversation