BookmarkSubscribeRSS Feed
pearson101
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

Code:

proc sort data=_all_clean_non;
by district;
run;
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;
run;

 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

 

1 REPLY 1
dw_sas
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;
run;

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

https://go.documentation.sas.com/?docsetId=etsug&docsetTarget=etsug_x11_syntax08.htm&docsetVersion=1... 

 

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;
run;

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.

DW

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 851 views
  • 0 likes
  • 2 in conversation