I'm trying to draw a variable with 3 reference lines calculated with user-selected parameters.
proc gplot data=DES;
plot yn*n /vref= u-&r &r u+&r;
run;
r is choosen by the user
u is calculated
how can I assign the value directly to vref?
You need to give the VREF= option a list of values. So U needs to be stored into a macro variable. Then you can use %EVAL(), for integers, or %SYSEVALF(), for real values, to calculate the values to pass as the reference lines.
So your GPLOT code will look like:
proc gplot data=DES;
plot yn*n /vref=( %sysevalf(&u-&r) &r %sysevalf(&u+&r) );
run;
Related
I want to sort my table of eigenvectors into ascending order. In order to do that I think need to turn my table of eigenvectors into a SAS data table. How do I do that? Below is part of the code I used to created my eigenvectors.
proc princomp data = test;
ID$ name$ DOB$ Job_Title$ Salary$
{DATA IS INSERTED HERE}
run;
Use the outstat= option in your proc princomp statement:
OUTSTAT= Option
OUTSTAT=SAS-data-set
creates an output SAS data set that contains means, standard deviations, number of observations, correlations or covariances, eigenvalues, and eigenvectors. If you specify the COV option, the data set is TYPE=COV or TYPE=UCOV, depending on the NOINT option, and it contains covariances; otherwise, the data set is TYPE=CORR or TYPE=UCORR, depending on the NOINT option, and it contains correlations. If you specify the PARTIAL statement, the OUTSTAT= data set contains R squares as well.
So I have seven different fields/variables in a SAS table each containing 1's and 0's. I need to - if at all possible - display these seven variables in one single pie. Is this possible? If so how? When I do this: pie variable1 variable2 / options I get two pies. Is there a way for me to combine them into one?
If your indicators reflect percentages of a whole WITHOUT overlap then yes you can.
This applies to multiple choice questions where you can select One of the Above. If it's a question that is select All that apply, then this would not be appropriate.
You cannot use the GCHART procedure but first need to summarize your data. Use a proc means to calculate the sums and then pass those to your PROC.
Proc means data = have stackods sum;
VAR ind1-ind7;
ODS OUTPUT summary=totals;
Run;
Use the TOTALS dataset in your gchart with the sum as the Pie statement. I don't recall what the variable is called.
I have a variable ideology that takes on values from 1 to 7. I've decided to make these continuous values into three groups using PROC FORMAT like so:
proc format;
value ideofmt
1-2='Lib or Extr Lib'
3-5='Mod Lib, Slight Lib or Slight Cons'
6-7='Cons or Extr Cons';
run;
I want to create a pie chart that takes into account my grouping of these continuous values, if possible without having to modify the data itself. What I've tried is:
proc gchart data=sasuser.project2;
pie ideology /noheading percent=arrow slice=inside value=inside coutline=black
woutline=2;
format ideology ideofmt.;
run;
This gets me a pie chart that has the group labels that I want, but the pie chart is split into 7 slices (corresponding to the 7 values) instead of 3 (corresponding to the 3 groups).
Any help with this would be much appreciated. Thanks!
Add the discrete option to your pie statement:
proc gchart data=sasuser.project2;
pie ideology /noheading percent=arrow slice=inside value=inside coutline=black discrete
woutline=2;
format ideology ideofmt.;
run;
quit;
Otherwise, I think SAS assigns slices based on quantiles of your data, ignoring formatted values.
Also, a quit statement is required at the end of proc gchart in addition to the run statement.
I generated a random sample from an exponential distribution and sorted them so they are going from lowest to highest value, giving me my order statistics. Now I need to get the values of the survival function at these numbers and plot them against the order statistics. I cannot seem to figure out how to get the list of these survival values in SAS, so I can plot them.
Survivor function estimates at the observed event times can be obtained from the LIFETEST procedure in SAS.
proc lifetest data = yourdata outsurv = survest;
time time2event*eventindicator(0);
run;
The output dataset created by the OUTSURV= option contains the survivor function estimates. Note that by default this gives the Kaplan-Meier estimate of the survivor function.
A plot of the estimated survivor function across time is produced automatically by LIFETEST. If you want to plot against order statistics, use the STEP statement in the SGPLOT procedure after computing your order statistics.
proc sgplot data = survandorder;
step x = order y = survival;
run;
First off, I know pretty much nothing about SAS and I am not a programmer but an accountant, but here it goes:
I am trying to compare two data sets to identify differences between them, so I am using the 'proc compare' command as follows:
proc compare data=table1 compare=table2
criterion=.01;
run;
This works fine, but it compares line by line and in order, so if table2 is missing a row half way through, then all entries after that row will be returned as not equal.
How do I ask the comparison to be made based on a variable so that the proc compare finds the value associated with variable X in table 1, and then makes sure that the same variable X in table 2 has the same value?
The ID statement in PROC COMPARE is used to match rows. This code may work for you:
proc compare data=table1 compare=table2 criterion=.01;
id X;
run;
You may need to use PROC SORT to sort the data by X before doing the PROC COMPARE. Refer to the PROC COMPARE documentation for details on the ID statement to determine if you should sort or not.
Here is a link to the PROC COMPARE documentation:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000057814.htm