proc sgpanel reg only on one modality of group - sas

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.

Related

sas 9.0 Put two graphics

I am facing a technical problem in SAS 9.2.
Here is an example code:
proc sgplot data=sashelp.class;
reg y=Age x=height;
run;
proc sgplot data=sashelp.class;
scatter y=Age x=weight;
run;
I would like to put the 2 graphics together.
How can I do it easily?
Thanks.

Trying to remove confidence bands and prediction bands from SAS REG procedure

My code
proc reg data=mydata plots=;
title "Correlation Between Estriol Levels and Birthweights";
model birthweight=estriol / clb cli clm;
run;
Plots the regression line and scatter plot but also includes the confidence bands and prediction bands. Is there a way I can hide one, the other, or both from the REG output?
I don't believe there's a way within PROC REG but you can accomplish something similar using PROC SGPLOT. See the documentation here for specifics such as modifying the colour/style or doing multiple lines.
Here's an example that uses the SASHELP.CLASS data set as an example.
proc sgplot data=sashelp.class;
reg x=age y=height;
run;
Documentation:
http://support.sas.com/documentation/cdl/en/grstatproc/69716/HTML/default/viewer.htm#p0mn6vl6clqbgyn1ivs69lezdxhf.htm
By using plots=; you are requesting the default set of plots in the output. You probably want to suppress the default set using plots(only)= and then specifying only the graphics you want.
See the PROC REG statement options at http://support.sas.com/documentation/cdl/en/statug/66859/HTML/default/viewer.htm#statug_reg_syntax01.htm

Normalize a variable (divide by its total)

I have a variable of weight, wprm, that takes integer values. I would like to have one that is the weight "normalized", that is to say wprm/sum(wprm)
I can do that by outputing a proc summary ant then a merge to put it back with the original data, and then dividing my wprm variable, but it seems a bit heavy, is there a simpler way ?
Use PROC STDIZE or PROC STANDARD - they both allow various normalization methods.
proc stdize data=have method=sum out=want;
var wprm;
run;
You can grab the macro %simple_normalize from here.
data test;
do i=1 to 10;
output;
end;
run;
%simple_normalize(test,i);
The other common option is SQL, but it will post a warning/note to the log that many people don't like.
proc sql;
create table want as
select a.*, a.wprm/sum(a.wprm) as weight
from have;
quit;

Plot of observation number

I want to make a plot between a variable and its observation number. From here http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect017.htm
I see that the keyword is OBS.
so thus my code is
proc gplot data=my_data;
plot OBS.*my_v;
run;
by I still get an error. What's the proper way to do this?
Your reference refers to proc reg not proc gplot. You may need to add the observation number in to the data set.
data my_data;
set my_data;
obs=_n_;
run;
proc gplot data=my_data;
plot OBS*my_v;
run;

Seasonal Sub Series Plot in 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;