BookmarkSubscribeRSS Feed
ammarhm
Lapis Lazuli | Level 10

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

2 REPLIES 2
JacobSimonsen
Barite | Level 11

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;

Ksharp
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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