Programming the statistical procedures from SAS

Frequency table with step increament

Reply
Regular Contributor
Posts: 163

Frequency table with step increament

Hi

I have been searching for this very simple thing. Creating a frequency table with certain increament steps

Let us say I have a continous variable taking values 1-100 and I have a thousand observations of that variable

What is the easiest wat to create a frequency table with a specific increamtnet, ie in groups of 10 or 20 or anything??

Using proc freq with formats seems a bit complicated for this task, or am i worng?

Regards

Super Contributor
Posts: 287

Re: Frequency table with step increament

One solution can be to define a format with relevant ranges. Do this with the cntlin option allows you to benefit of the do-loop in a datastep:

data abc;

  do i=0 to 100;

   output;

  END;

run;

data myformat;

  type='N';

  fmtname='myformat';

  do start=0 to 100 by 5;

    end=start+4;

     label=compress(put(start,best3.)||'-'||put(end,best3.));

    output;

  end;

run;

proc format cntlin=myformat;

run;

proc freq data=abc;

  format i myformat.;

  table i;

run;

Super User
Posts: 9,766

Re: Frequency table with step increament

OR you could try proc rank to split these data into a couple of groups.

data abc;
  do i=1 to 100;
   output;
  END;
run;
proc rank data=abc out=temp groups=10;
var i;
ranks group;
run;
proc freq noprint data=temp;
by group;
tables i/out=want nocum nopercent;
run;

Xia Keshan

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