BookmarkSubscribeRSS Feed
ebardaka5
Calcite | Level 5

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

2 REPLIES 2
Ksharp
Super User

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

ebardaka5
Calcite | Level 5

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 690 views
  • 0 likes
  • 2 in conversation