DATA Step, Macro, Functions and more

adding a normal curve to a histogram

Accepted Solution Solved
Reply
Super Contributor
Posts: 345
Accepted Solution

adding a normal curve to a histogram

 

proc univariate data=numtem10;

VAR ACOSTY10;

histogram;

run;

ods select ParameterEstimates GoodnessOfFit FitQuantiles Bins MyPlot;

proc univariate data=numtem10;

histogram acosty / normal(percents=20 40 60 80 midpercents)

name='MyPlot distribution';

inset n normal(ksdpval) / pos = ne format = 6.3;

run;

 

my first one was able to generate a histogram but I want to add a curve to it. But the second cannot generate any figures.

Here is the error message. Any advice? Thanks.

**************

Output 'MyPlot' was not created. Make sure that the output object name, label, or path

is spelled correctly. Also, verify that the appropriate procedure options are used to

produce the requested output object. For example, verify that the NOPRINT option is not

used.

 


Accepted Solutions
Solution
‎06-06-2016 01:25 PM
Respected Advisor
Posts: 4,920

Re: adding a normal curve to a histogram

You may have excluded the graphs from ODS destinations. Try preceeding your proc univariate call with 

 

ODS select all;

PG

View solution in original post


All Replies
Super Contributor
Posts: 345

Re: adding a normal curve to a histogram

I tried two variables, acosty is the orginal variable, acosty10 is to break into deciles. None can generate a histogram with a normal curve.

In addition to the error message, there is a note below

 

NOTE: At least one W.D format was too small for the number to be printed. The decimal may be

shifted by the "BEST" format

 

SAS Super FREQ
Posts: 3,752

Re: adding a normal curve to a histogram

Put the MIDPERCENTS option outside of the parentheses:

proc univariate data=sashelp.class;
var height weight;
histogram height weight / normal(percents=20 40 60 80) midpercents;
inset n normal(ksdpval) / pos = ne format = 6.3;
run;

Also, the NAME= option is only for traditional graphics. It doesn't do anything when you use ODS graphics.

Super Contributor
Posts: 345

Re: adding a normal curve to a histogram

I am unable to get a curve with your code. below is the note I got. The error message disappeared but the note is same

 

NOTE: At least one W.D format was too small for the number to be printed. The decimal may be

shifted by the "BEST" format.

Super User
Posts: 11,343

Re: adding a normal curve to a histogram

The note about a format says that you have assigned a format that does not have enough positions to display the values you request.

 

a 6.3 format will display up to 99.999 (6 total characters with 3 decimals). If you variable is larger than 100 you would get that message. If the values much larger, say 1,000,000 you would get exponential notation such as 1E6.

So make the width of any formats used wider, try 9.3

Super Contributor
Posts: 345

Re: adding a normal curve to a histogram

NO curve nor histogram was generated.

 

1858 proc univariate data=numtem10;

1859 var acosty acost;

1860 histogram acosty acost / normal(percents=20 40 60 80) midpercents;

1861 inset n normal(ksdpval) / pos = ne format = 9.3;

1862 run;

NOTE: PROCEDURE UNIVARIATE used (Total process time):

real time 3.16 seconds

cpu time 0.32 seconds

 

Solution
‎06-06-2016 01:25 PM
Respected Advisor
Posts: 4,920

Re: adding a normal curve to a histogram

You may have excluded the graphs from ODS destinations. Try preceeding your proc univariate call with 

 

ODS select all;

PG
Respected Advisor
Posts: 4,920

Re: adding a normal curve to a histogram

The note "At least one W.D format..." does not prevent the production of a graph. The problem is elsewhere. Please post the entire log for what you have tried.

PG
Super Contributor
Posts: 345

Re: adding a normal curve to a histogram

 

For the one I am asking, I did not see any error message, but it just did not generate.

I did see another warning message on another statement

WARNING: Most ODS graphics with more than 5000 points have been suppressed. Use the

PLOTS(MAXPOINTS= ) option in the PROC REG statement to change or override the cutoff.

Respected Advisor
Posts: 4,920

Re: adding a normal curve to a histogram

The message is self-explanatory. Making a graph with more than 5000 points will take some time and may not be very informative. 

PG
SAS Super FREQ
Posts: 3,752

Re: adding a normal curve to a histogram

It is very important that you either 

1) Post your data, or

2) Post any NOTEs, WARNINGs, or ERRORs that appear in the log.  

 

Another suggestion: Please try to reproduce your problem by using a small data set such as Sashelp.Class. That will make it easier for those who are trying to diagnose your errors. For example, if you say "this code works with Sashelp.Class but does not work with my real data, that will let us know that the issue is with the data, not with the syntax.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 548 views
  • 6 likes
  • 4 in conversation