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
How about using proc rank to group these raw data ,then proc freq get these group's freq ?
Thank you for your reply
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.