Seasonal Sub Series Plot in SAS - sas

I'm studying a seasonal monthly time series and I like to plot the Seasonal Sub Series Plot or a Box Plot by Month in SAS.
Somthing like the ones at the bottom of the page at the following link:
http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc443.htm
I'm not sure how exactly to get this done in SAS. I appreciate any help.
SE

Can't speak to the seasonality, but box plots are pretty simple. Assuming you create a SAS dataset from the data in that web site, try this:
proc format ;
value mn_name 1='January'
2='February'
3='March'
4='April'
5='May'
6='June'
7='July'
8='August'
9='September'
10='October'
11='November'
12='December'
other='Invalid';
run;
proc sort data=have;
by month;
run;
proc boxplot data=have;
plot Oscillation*month;
format month mn_name.;
run;

Related

proc sgpanel reg only on one modality of group

I have some computing problem with SAS 9.2.
Here is my code:
data test;
set sashelp.cars;
WHERE Make in ('Acura', 'Audi');
run
proc sgpanel data=test;
panelby origin;
reg y=Weight x=Length/group=Make;
run;
The regression option is applied on the 2 modalities of the variable Make.
Is it possible to allpy it only one one of them? For instance, only on the Make 'Audi'?
Thanks a lot.
Just make two separate plots with sgplot.
/* regression plot for the one you need the regression */
proc sgplot data=sashelp.cars;
WHERE Make eq 'Audi';
reg y=Weight x=Length/group=Make;
run;
/* scatter plot for the one you need no regression */
proc sgplot data=sashelp.cars;
WHERE Make eq 'Acura';
scatter y=Weight x=Length/group=Make;
run;
Also not I integrated the selection in the graphical procedure.

I need to find the confidence intervals for proportions using stratified data

I'm trying to report estimates of proportions of subjects of a stratified random sample
I've tried every website I can find for SAS proc surveymeans, and I don't understand what I'm doing wrong.
data b;
set Data;
keep id texting section;
run;
proc surveyselect data=b out=samp_b method=srs n=(15,12,10,8)
seed=123;
strata section;
run;
proc surveymeans data=samp_b;
strata section;
weight SamplingWeight;
var texting;
run;
I should get confidence intervals for the strata, but they are not showing up. Also I need confidence intervals for the proportions!
I don't know what version of SAS/STAT you are using, but per SAS/STAT 9.2 Proc Surveymeans documentation pages, you can do one or both of the following:
1) Add the relevant statistics keywords to the proc surveymeans statement
https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveymeans_sect007.htm
In the PROC SURVEYMEANS statement, you also can use statistic-keywords to specify statistics for the procedure to compute. Available statistics include the population mean and population total, together with their variance estimates and confidence limits. You can also request data set summary information and sample design information.
The available statistics keywords are listed and described on these pages:
https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveymeans_a0000000238.htm
https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_surveymeans_sect007.htm#statug.surveymeans.smeanskeys
So, to print the 95% two-sided confidence interval for the mean, you would add CLM to the end of your Proc Surveymeans statement.
2) Save the Statistics table with confidence intervals to a separate SAS dataset with an additional ods output Statistics=MyStat; statement, per these instructions.

Add row percentage within top column in proc tabulate (SAS)

I am using Proc tabulate in SAS and I want to make a table like this example:enter image description here
As you can see, I want to calculate the rowpctn within each year. My problem is that i don't know where to write the rowpctn in the code, and after searching the web for an hour, I still haven't been able to find the answer.
My code looks like this:
Proc tabulate Data=Have;
class year gender question_1;
table gender, year*question_1;
run;
Where do I have to state the rowpctn to get the desired result?
While waiting for a response, I kept searching the internet for an answer, and I managed to find a solution myself.
The code is below:
Proc tabulate Data=Have;
class year gender question_1;
table gender*pctn<question_1>, year*question_1;
run;

Boxplot in SAS using proc gchart

First question, is it possible to produce a boxplot using proc gchart in SAS?
If it is possible, please give me a brief idea.
Or else, on the topic of using proc boxplot.
Suppose I have a dataset that has three variables ID score year;
something like,
data aaa;
input id score year;
datalines;
1 50 2008
1 40 2007
2 30 2008
2 20 2007
;
run;
I want to produce a boxplot showing for each ID in each year. (So in this case, 4 boxplots in a single plot)
How can i achieve this?
I have tried using
proc boxplot data=aaa;
plot score*ID;
by year;
run;
However, this is not working as we can see year is not sorted by order.
Is there a way to get other this?
You need to sort your input dataset first. Run this
proc sort data = aaa;
by year;
run;
and then your proc boxplot should work as written.
This is quite easy to do with sgplot, which is part of the newer ODS Graphics suite which is available in base SAS.
proc sgplot data=sashelp.cars;
vbox mpg_city/category=type group=origin grouporder=ascending;
run;
You would use category=id and group=year in your example data - you get one separate tick on the x axis for each category and then you get a separate bar clustered together for each group.

plot entire time series in SAS?

I am trying to make a forecast, and I want to see the entire time series, with the forcasted period at the end (need to compare with another graph of this kind).
SAS 9.4 does not want to comply, however, and only shows me the forecasting part.
What can I do to remedy this?
The code I'm using is:
Proc arima data=logtabell;
identify var=y(12) nlag=24;
estimate p=1 q=2;
forecast lead=12 interval=month id=date out=results;
run;
Your out= dataset will contain all values by default. If you want to specifically see the full graph that it outputs, add the plots option:
proc arima data=logtabell plots=forecast(forecast);
Or, just do it the easy way by getting every plot:
proc arima data=logtabell plots = all;
Also, make sure ods graphics on; is set.
SAS procedures have an out=resultSet option, from which you can get the results in a dataset.
Combine this output with your time serious in one graph created with proc sgplot