BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
melgotts
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
I think it's possible via template modifications but I'm not sure it's worth it. I would personally use SGPLOT.

View solution in original post

7 REPLIES 7
Reeza
Super User
Show your work please.
ballardw
Super User

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;
melgotts
Calcite | Level 5

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!

Tom
Super User Tom
Super User

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.

Reeza
Super User
I think it's possible via template modifications but I'm not sure it's worth it. I would personally use SGPLOT.
melgotts
Calcite | Level 5

Thank you for the replies! I'll use SGPLOT.

ballardw
Super User

@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.

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!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 1134 views
  • 4 likes
  • 4 in conversation