Has anyone already done the calculation for CVaR (Conditional Value at Risk) in SAS? Can I have an example or reference material please?
Thanks!
Conditional Value at Risk is a value provided by the SAS Risk Dimensions product, available through PROC RISK.
Related
I am not an English speaker, so first I am sorry for my English.
I am using SAS, and I want to calculate R-Square and bound beta coefficients over zero at a time.
I've tried and searched several procedures such as PROC MODEL OR PROC REG.
However, according to a SAS community, only 'BOUNDS' can be used with PROC MODEL but not RSQ and only equation restriction can be used with PROC REG.
Is there some way to solve it at a time? Thank you.
We have a large dataset, and when we run proc mixed or hpmixed on a sample of the data, we get the same coefficients for the continuous variables. However, for HPMIXED, SAS ignores the reference values we give it for categorical variables, and the intercept becomes 0.
Is there an option to force HPMIXED to use an intercept and to 'not ignore' the ref="" values we choose?
Thank you in advance for your help!
I'm going to ask this with an example...
Suppose i have a data set where each observation represents a person. Two of the variables are AGE and HASADOG (and say this has values 1 for yes and 2 for no.) Is there a way to run a PROC FREQ (by AGE*HASADOG) that forces SAS to include in the report a line for instances where the count is zero?
By this I mean: if there is a particular value for AGE such that no observation with this AGE value has a 1 in the HASADOG variable, the report will still include a row for this combination (with a row percent of 0.)
Is this possible?
The SPARSE option in PROC FREQ is likely all you need.
proc freq data=sashelp.class;
table sex*age / sparse list;
run;
If the value is nowhere in your data set at all, then there's no way for SAS to know it exists. In this case you'd need a more complex solution, basically a way to tell SAS all values you would be using ahead of time. This can be done via a PRELOADFMT or CLASSDATA option on several procs. There are asked an answered questions on this topic here on SO, so I won't provide a solution for this option, which seems beyond the scope of your question.
could you please give me some hints for identifying the nature of missingness for categorical variables' missing value? I mean, I gave a fast search on google scholar but I didn't find anything related with this. How could I understand if missing-values are missing completely at random, are they missing at random or finally, they are missing not at random? Except studying the domain I can't think anything. Links to some papers are appreciated, Thanks in advance.
(I'll add it in sas environment but the question is not specifically related with this language).
Since you've tagged this as SAS, one approach you could take would be to create a boolean variable for each of your categorical variables indicating whether or not it has a missing value in each row. Then you could do whatever analysis you like on the frequency of missing values, using the flags. E.g. you could use proc corr to see if missing values of one variable correlate with values of other variables.
E.g. suppose you have a situation like this:
data example;
set sashelp.class;
if AGE > 14 then call missing(SEX);
SEX_MISSING_FLAG = missing(SEX);
run;
Then you could spot it by running the following:
proc corr data = example outp= corr;
var age weight height sex_missing_flag;
run;
Output:
_TYPE_,_NAME_,Age,Weight,Height,SEX_MISSING_FLAG
MEAN,,13.32,100.03,62.34,0.26
STD,,1.49,22.77,5.13,0.45
N,,19.00,19.00,19.00,19.00
CORR,Age,1.00,0.74,0.81,0.78
CORR,Weight,0.74,1.00,0.88,0.64
CORR,Height,0.81,0.88,1.00,0.55
CORR,SEX_MISSING_FLAG,0.78,0.64,0.55,1.00
Background: I have a categorical variable, X, with four levels that I fit as separate dummy variables. Thus, there are three total dummy variables representing x=1, x=2, x=3 (x=0 is baseline).
Problem/issue: I want to be able to calculate the value of a linear combination (i.e. using SAS as a calculator) of these dummy variables. For example, 2*B1 + 2*B2 + B3.
In Stata, this can be done using the lincom command, which uses the stored beta estimates to calculate linear combinations of the parameters.
In SAS in a procedure such as PROC GLM, I think I should use the ESTIMATE statement, but I'm not sure how I would specify the "weights" for each variable in this case.
You are looking for PROC SCORE. This takes output regression or factor estimates and scores a new data set. See here for an example. http://support.sas.com/documentation/cdl/en/statug/66859/HTML/default/viewer.htm#statug_score_examples02.htm
FYI, PROC MODEL does allow this in the model statement, which may be less work than PROC SCORE. I know PROC MODEL can be used readily in place of PROC REG, but I'm not sure how advanced of modeling PROC MODEL does, so it may not be an option for more complex models. I was hoping for something with less coding, but given the nature of SAS, I think this and PROC SCORE are the best I'm going to get.
What if you add your linear combination as a variable in your input dataset?
data myDatasetWithLinCom;
set mydata;
LinComb=2*(x=1)+ 2*(x=2)+(x=3); /*equvilent to 2*B1 + 2*B2 + B3*/
run;
then you can specify LinComb as one of the explanatory variables and you can lookup the coefficient directly from the output.