BookmarkSubscribeRSS Feed
brook2
Fluorite | Level 6

*** Not spam  !!!!!  real programming question ** Thanks 

 

I have data (2584 record)  with three columns ( subject , Education level as Educ and income during 2005 as Income2005) and a category of five types under education level  ( =12, 13-15 , 16, <12, >16) this is a bucket that contains income for each education distribution at Income2005  column  . I want to draw Histogram and QQ plot of income 2005 distro side by side for each educ level . why this code is not working ? Thanks 

 

proc import datafile='/folders/myfolders/ex0525.csv'
DBMS=csv out=IncomeData replace;
run;
proc print data=IncomeData;
run;

proc univariate data = incomedata;
class Educ;
var income2005;
run;

** the above code works fine but the below code doesn't plot the 5 histograms and 5 QQ plots of Income 2005 distribution for each Educ category
it just spits out Descriptive stat as Educ= 12 , ( there is no error but unneeded output)

proc univariate data = incomedata;
by Educ;
histogram income2005;
qqplot income2005;
run;

 

5 REPLIES 5
PGStats
Opal | Level 21

Note that PROC UNIVARIATE uses the formatted values of the CLASS variables to determine the classification levels, but uses the internal values for BY processing. Problems related to this difference typically generate errors in the SAS log.

PG
brook2
Fluorite | Level 6

There is no error generated , it just gives result ( descriptive stat) for the code shown. I want to generate histogram and qq plot side by side. I am expecting a result set showing all his and QQ under each category of Educ ( <12 yrs  ,12yrs  , 13-15 yrs , 16 yrs  , >16 yrs ).Can you help me with a working solution using the code or any other way as an example.Thanks 

PGStats
Opal | Level 21

Here is an example that works for me:

 

proc sort data=sashelp.heart out=sortedHeart; by smoking_status; run;

ods pdf file="Brook2_example.pdf";
proc univariate data = sortedHeart noprint;
where smoking_status is not missing;
by smoking_status;
histogram cholesterol; 
qqplot cholesterol; 
run;
ods pdf close;

Result pdf attached.

 

 

PG
brook2
Fluorite | Level 6

@PGStats  Thanks for your time and help . But I am still missing three categories for Educ <12 , Educ 13-15 Educ >16  catagory , it is only giving me Educ =12 and Educ =16 , looks like it is not taking the less than or greater than or in between values 

I reused the code you posted below ,here is the result  

 

brook2
Fluorite | Level 6
For some reason I cant copy paste my actual code like u did , but I have attached the result set in pdf in the next thread.
I cant even add the screen shot of the code and attache it as image file !! little weird ! but I have exactly replicated your code!! thanks

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1555 views
  • 0 likes
  • 2 in conversation