Hi.
Is there a way to create a whole series of individual time series plots utilizing a macro (for all my independent variables, i.e. '&indvar') over a series of years (C_EDDYR)? (each plot would represent each individual '&indvar' by year)
I was able to get my trend test to work with the macro variable (see below):
proc freq data=t;
tables C_EDDYR*(&indvar) / trend;
where gastro_isol=0;
run;
********************************************************
...but now, when I try various 'plotting codes' with the macro (to plot the trend I get statistics on above), I'm not able to get what I'm looking for:
/*try to plot time trend*/
proc gplot data=t;
plot C_EDDYR*(&indvar);
symbol1 v=star c=blue;
title "Time Series Plot for (&indvar) and Year of Estimated Delivery";
where gastro_isol=0;
run;
quit;
title;
proc sgpanel data=t ;
panelby (&indvar);
series x=C_EDDYR y=(&indvar);
where gastro_isol=0;
run;
Any assistance would be greatly appreciated.
Thanks,
-Taylor (using SAS V 9.4)
So, you haven't written a macro, and you haven't given the macro variable &indvar a value.
But a macro isn't needed here. Nor is a macro variable needed here. Unless there are other complications you haven't told us about.
Use the search and replace option in the SAS editor to replace the string "&indvar" with the corresponding string of variables that you are interested in. Done. No macros. No macro variables.
Okay, I see now. Macros are usually used to create dynamic code, which can change depending on other pieces of data (for example, if the user requests the analysis for North America, you may have different variables than if the request is for Europe).
In your case, you seem to be using the macro variable to save some typing, certainly a valid use of macro variables (I do that sometimes too).
So, you need to turn on some options
options mprint mlogic symbolgen;
and then run the code. I would need to see the SASLOG to determine what is the problem here.
This is very frustrating, because nowhere have you actually ever stated what the problem is, other than you need help with macros. What is the problem you see when you run this code?
There is a warning about the title statement, is that the problem? Or something else?
This is very vague as well. The Cochran-Armitage test is a statistic, a single number, I don't understand the concept of plotting a single number.
proc freq data=Pain;
tables Adverse*Dose / trend measures cl
plots=freqplot(twoway=stacked) out=freq_counts;
test smdrc;
exact trend / maxtime=60;
weight Count;
title 'Clinical Trial for Treatment of Pain';
run;
proc sgplot data=freq_counts;
title 'Adverse By Dose';
series x=dose y=count / group=adverse
markers
markerattrs=(symbol=circlefilled)
datalabel;
run;
produces the line chart in the screen shot below.
Line plot of adverse reactions by dose
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.