BookmarkSubscribeRSS Feed
Calcite | Level 5

I have a time series data containing more than15 variables by group (district). I am trying to run a pro x11 such that the output will have the 15 variables and its accompanying adjusted values. I am currently using the following code for one variable. My goal is to eventually create a sgpanel of a time series each of the variable by district. Instead of coding for each variable, I thought automating it in someway would be helpful. I think I would have to find a way produce a dataset that has all the variable along side with its adjusted values.I saw that loops can be used to produce graphs, I was wondering if it can be used for proc x11.

Data looks like:

district  variable1  variable2   variable3 .......variable15  date_new   
gotam          2         7            8              3         2018/01


proc sort data=_all_clean_non;
by district;
proc x11 data = _all_clean_non noprint;
monthly additive date = date_new;
by district;
var mean_malaria_rate;
tables a1 d12;
output out = test_all_mal a1 = mean_malaria_rate d12 = adj;run;
proc sgpanel data=test_all_mal;
panelby district / novarname ;
rowaxis label='Number of malaria cases';
vline date_new / response=mean_malaria_rate;
vline date_new / response=adj markers markerattrs=(color=blue symbol='circle') lineattrs=(color=blue) legendlabel="trend cycle";
colaxis fitpolicy=thin interval=YEAR;

 What I want the output to eventually look like:

district varia1 varia_adj  varia2  varia2_adj varia3  varia3_adj...varia15 varia15_adj date_new   
gotam       2        1         7          1         8        3          3         2     2018_01


SAS Employee

Hi @pearson101 ,


PROC X11 allows you to specify more than one variable in the VAR statement, therefore, you can obtain your desired output data set by specifying something like the following, where Var1, Var2, Var3 and Var4 are the analysis variables:


proc x11 data = _all_clean_non noprint;
monthly additive date = date_new;
by district;
var var1 var2 var3 var4;
tables a1 d12;
output out = test_all_mal a1 = var1 var2 var3 var4 
                         d12 = var1_adj var2_adj var3_adj var4_adj;

For more details, please see the following link to the OUTPUT statement in the PROC X11 documentation: 


If you have a large number of analysis variables and you do not want to list out the variable names in the A1= and D12= options in the OUTPUT statement, then you might want to consider using PROC X13 for your analysis rather than PROC X11.  The following code will perform a similar analysis to the code above without having to specify the variable names in the OUTPUT statement.  They are generated automatically by the procedure:

proc x13 data=_all_clean_non noprint date=date_new interval=month;
by district;
var var1 var2 var3 var4;
x11 mode=add;
output out=test_all_mal a1 d12;

In this case, the OUT= data set generated by PROC X13 will have variables:  

district date_new var1_a1 var1_d12 var2_a1 var2_d12 ... var4_a1 var4_d12


The D12 table results generated by PROC X13 might be slightly different than those generated by PROC X11 due to updates to the Census Bureau algorithms used to generate the trend-cycle component.


I hope this helps you generate the output data set you want to use in your subsequent PROC SGPANEL steps.





Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2 in conversation