Help using Base SAS procedures

Estimate data for histogram without the Histogram Statement

Reply
New Contributor
Posts: 2

Estimate data for histogram without the Histogram Statement

Hello,

I am trying to use data from the Luxembourg Income Study online database. It is a database of household surveys from different countries. This database has a user interface through which I can analyze the data using SAS, but not directly access or see the data. I cannot create plots, and I cannot print the raw data. For example, the following frequency statement gets rejected because it is considered printing of raw data:

*** dhi = disposable household income, hpopwgt = inflated household weight ***;

PROC FREQ DATA=&it04h;

TABLES dhi;

WEIGHT hpopwgt;

RUN;

I need to create a histogram of the income distribution. I cannot use the histogram statement in proc univariate because plots are not allowed. I only need the table that gives the bin midpoint and the observed percent. I am looking for a different piece of code that would give me the same results that the code below gives (apart from the plot obviously):

DATA Italy04;

     SET &it04h;

     DO i=1 TO hpopwgt;

          OUTPUT;

     END;

RUN;

PROC UNIVARIATE DATA=Italy04;

    VAR dhi;

    HISTOGRAM dhi / MIDPERCENTS NMIDPOINTS=100;

RUN;

I am new to SAS and I very much appreciate your help Smiley Happy

Grand Advisor
Posts: 9,475

Re: Estimate data for histogram without the Histogram Statement

How about using   proc rank  to group these raw data ,then  proc freq  get these group's freq ?

New Contributor
Posts: 2

Re: Estimate data for histogram without the Histogram Statement

Thank you for your reply Smiley Happy

I ended up using the following but I will check proc rank as well:

proc means data=&it04h mean min max;

var dhi;

output out=tmp min=mindhi max=maxdhi;

run;

data forbin;

set tmp;

bin=(maxdhi - mindhi)/100;

drop i;

retain fmtname 'bin' type 'n';

do i = 0 to 99;

  binstart = mindhi+(i*bin);

  binend = binstart + bin-0.01;

  label = cat(binstart,"  to  ", binend);

  output;

end;

run;

proc format cntlin=forbin (rename=(binstart=start binend=end)); run;

proc freq data=&it04h;

format dhi bin.;

table dhi ;

weight hpopwgt;

run;

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