Hello,
Is it possible to use a macro variable in the HREF= statement for Proc Univariate? I am running multiple histograms and would like to use multiple rows of means from a previous Proc Means to superimpose a reference line on each the histograms. I need the means specific to a prior run and not what I'd get from the Proc Univariate. If I use the refline statement in Proc SGPLOT, I'm able to use the macro variable, but I'm struggling with this for HREF.
I'm essentially following this example (https://blogs.sas.com/content/iml/2016/08/10/bootstrap-confidence-interval-sas.html), but instead of running the Proc SGPLOT after the bootstrapping, I'd like to use Univariate to create the histograms. Does HREF allow you to use a macro variable? Or will I have to either run say 10 different Univariates or instead figure out how I can do what I want with SGPLOT?
Thank you,
Melissa
Is there a reason not to use the SGPLOT Histogram?
This places two references at the given values in the plot. The values need to be space delimited.
%let refs = 80000 600000; proc univariate data=sashelp.shoes ; histogram sales /href= &refs. ; run;
Thank you for the responses. I could certainly use SGPLOT, but I'd like to figure this out in Univariate if possible. I only want 1 refline per histogram, so the code with the 2 reflines won't work. From my Proc Means, I have a column of means (not my data, just an example):
Var Mean
Red 5
White 12
Rose 33
Then I want to run the histograms in univariate after I've bootstrapped. So I would run the univariate by group (my variable, wine in my example) and get a histogram for each wine. Then I want to bring the means from above and put them into the HREF. When I try to write a macro, I get an error (ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant. ERROR 202-322: The option or parameter is not recognized and will be ignored.)
So I'm wondering if what I'm trying to do is not possible?
Thank you!
Show the code. Show the log.
Get an example of code that works WITHOUT any macros or macro variables first. Then you can work on how to generate the code.
Thank you for the replies! I'll use SGPLOT.
@melgotts wrote:
Thank you for the responses. I could certainly use SGPLOT, but I'd like to figure this out in Univariate if possible. I only want 1 refline per histogram, so the code with the 2 reflines won't work. From my Proc Means, I have a column of means (not my data, just an example):
Var Mean
Red 5
White 12
Rose 33
Then I want to run the histograms in univariate after I've bootstrapped. So I would run the univariate by group (my variable, wine in my example) and get a histogram for each wine. Then I want to bring the means from above and put them into the HREF. When I try to write a macro, I get an error (ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant. ERROR 202-322: The option or parameter is not recognized and will be ignored.)
So I'm wondering if what I'm trying to do is not possible?
Thank you!
The example I posted would work with one reference line as well.
Your original post of "I am running multiple histograms and would like to use multiple rows of means from a previous Proc Means to superimpose a reference line on each the histograms." isn't exactly clear as to how many items you want where.
And again we would ask: Post log with the code that you ran including any messages and errors. Post such into a code box opened with the forum's {I} icon.
Showing code and data describes what you attempted much better than "I followed the example in SOMELINK.HTML" because we cannot tell exactly how you implemented the code or whether your data matched the same structure as the link used.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.