SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Count numeric value's frequency

Reply
Contributor
Posts: 34

Count numeric value's frequency

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. 

Super User
Super User
Posts: 7,968

Re: Count numeric value's frequency

Posted in reply to JinboZhao

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;
Super User
Posts: 5,509

Re: Count numeric value's frequency

Posted in reply to JinboZhao

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.

Ask a Question
Discussion stats
  • 2 replies
  • 128 views
  • 0 likes
  • 3 in conversation