BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sreenu
Calcite | Level 5
I have used this for program for copula simulation


data returns;
input ret_x ret_y ret_z;
cards;
0.004182 0.003503 0.584
-0.027960 -0.000582 0.54
0.006732 0.025611 0.14
-0.033435 -0.002838 -0.24
0.029560 0.010814 -0.4
-0.003054 -0.001689 0.8
-0.012255 -0.012408 0.9
0.013958 0.003427 0.14
-0.011318 -0.017075 0.14
-0.022587 0.002316 0.28
;
/* Copula estimation */
proc copula data = returns;
var ret_x ret_y ret_z;
fit normal / outcopula=estimates;
/* keep only correlation estimates */
data estimates;
set estimates;
keep ret_x ret_y ret_z;
/* Copula simulation */
proc copula;
var ret_x ret_y ret_z;
define cop normal (cor = estimates);
simulate cop / ndraws = 500
outuniform = simulated_uniforms
plots=(data=uniform scatter);
run;


Got this log :


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 data returns;
72 input ret_x ret_y ret_z;
73 cards;

NOTE: The data set WORK.RETURNS has 10 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 521.87k
OS Memory 28840.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 50 Switch Count 2
Page Faults 0
Page Reclaims 131
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

84 ;

85 /* Copula estimation */
86 proc copula data = returns;
87 var ret_x ret_y ret_z;
88 fit normal / outcopula=estimates;
89 /* keep only correlation estimates */

NOTE: The data set WORK.ESTIMATES has 3 observations and 9 variables.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.04 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 2572.53k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 51 Switch Count 2
Page Faults 0
Page Reclaims 517
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

90 data estimates;

91 set estimates;
92 keep ret_x ret_y ret_z;
93 /* Copula simulation */

NOTE: There were 3 observations read from the data set WORK.ESTIMATES.
NOTE: The data set WORK.ESTIMATES has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 801.06k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 52 Switch Count 2
Page Faults 0
Page Reclaims 143
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264

94 proc copula;

95 var ret_x ret_y ret_z;
96 define cop normal (cor = estimates);
___
1
WARNING 1-322: Assuming the symbol CORR was misspelled as cor.
97 simulate cop / ndraws = 500
98 outuniform = simulated_uniforms
99 plots=(data=uniform scatter);
____
22
202
ERROR 22-322: Syntax error, expecting one of the following: ), DATATYPE, DISTRIBUTION, NONE.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
100 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SIMULATED_UNIFORMS may be incomplete. When this step was stopped there were 0 observations and 0
variables.
WARNING: Data set WORK.SIMULATED_UNIFORMS was not replaced because this step was stopped.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 339.25k
OS Memory 29864.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 53 Switch Count 0
Page Faults 0
Page Reclaims 52
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16

101
102
103 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
115
Please help me to solve this and help me to add same data using excel sheet.
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You didn't mention what version of SAS you are running, but here is a link to the most recent doc.

1. The correct syntax for the DEFINE statement is 

     define cop normal (corr = estimates);

2. The correct syntax for the PLOTS option is

    plots=(datatype=uniform);

 

If you are using an older version of SAS that might have different syntax, consult the documentation for your version.

View solution in original post

8 REPLIES 8
sreenu
Calcite | Level 5
I have used this for program for copula simulation


data returns;
input ret_x ret_y ret_z;
cards;
0.004182 0.003503 0.584
-0.027960 -0.000582 0.54
0.006732 0.025611 0.14
-0.033435 -0.002838 -0.24
0.029560 0.010814 -0.4
-0.003054 -0.001689 0.8
-0.012255 -0.012408 0.9
0.013958 0.003427 0.14
-0.011318 -0.017075 0.14
-0.022587 0.002316 0.28
;
/* Copula estimation */
proc copula data = returns;
var ret_x ret_y ret_z;
fit normal / outcopula=estimates;
/* keep only correlation estimates */
data estimates;
set estimates;
keep ret_x ret_y ret_z;
/* Copula simulation */
proc copula;
var ret_x ret_y ret_z;
define cop normal (cor = estimates);
simulate cop / ndraws = 500
outuniform = simulated_uniforms
plots=(data=uniform scatter);
run;


Got this log :


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 data returns;
72 input ret_x ret_y ret_z;
73 cards;

NOTE: The data set WORK.RETURNS has 10 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 521.87k
OS Memory 28840.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 50 Switch Count 2
Page Faults 0
Page Reclaims 131
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

84 ;

85 /* Copula estimation */
86 proc copula data = returns;
87 var ret_x ret_y ret_z;
88 fit normal / outcopula=estimates;
89 /* keep only correlation estimates */

NOTE: The data set WORK.ESTIMATES has 3 observations and 9 variables.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.04 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 2572.53k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 51 Switch Count 2
Page Faults 0
Page Reclaims 517
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

90 data estimates;

91 set estimates;
92 keep ret_x ret_y ret_z;
93 /* Copula simulation */

NOTE: There were 3 observations read from the data set WORK.ESTIMATES.
NOTE: The data set WORK.ESTIMATES has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 801.06k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 52 Switch Count 2
Page Faults 0
Page Reclaims 143
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264

94 proc copula;

95 var ret_x ret_y ret_z;
96 define cop normal (cor = estimates);
___
1
WARNING 1-322: Assuming the symbol CORR was misspelled as cor.
97 simulate cop / ndraws = 500
98 outuniform = simulated_uniforms
99 plots=(data=uniform scatter);
____
22
202
ERROR 22-322: Syntax error, expecting one of the following: ), DATATYPE, DISTRIBUTION, NONE.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
100 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SIMULATED_UNIFORMS may be incomplete. When this step was stopped there were 0 observations and 0
variables.
WARNING: Data set WORK.SIMULATED_UNIFORMS was not replaced because this step was stopped.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 339.25k
OS Memory 29864.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 53 Switch Count 0
Page Faults 0
Page Reclaims 52
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16

101
102
103 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
115
Please help me to solve this and help me to add same data using excel sheet.
sreenu
Calcite | Level 5
I have used this for program for copula simulation


data returns;
input ret_x ret_y ret_z;
cards;
0.004182 0.003503 0.584
-0.027960 -0.000582 0.54
0.006732 0.025611 0.14
-0.033435 -0.002838 -0.24
0.029560 0.010814 -0.4
-0.003054 -0.001689 0.8
-0.012255 -0.012408 0.9
0.013958 0.003427 0.14
-0.011318 -0.017075 0.14
-0.022587 0.002316 0.28
;
/* Copula estimation */
proc copula data = returns;
var ret_x ret_y ret_z;
fit normal / outcopula=estimates;
/* keep only correlation estimates */
data estimates;
set estimates;
keep ret_x ret_y ret_z;
/* Copula simulation */
proc copula;
var ret_x ret_y ret_z;
define cop normal (cor = estimates);
simulate cop / ndraws = 500
outuniform = simulated_uniforms
plots=(data=uniform scatter);
run;


Got this log :


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 data returns;
72 input ret_x ret_y ret_z;
73 cards;

NOTE: The data set WORK.RETURNS has 10 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 521.87k
OS Memory 28840.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 50 Switch Count 2
Page Faults 0
Page Reclaims 131
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

84 ;

85 /* Copula estimation */
86 proc copula data = returns;
87 var ret_x ret_y ret_z;
88 fit normal / outcopula=estimates;
89 /* keep only correlation estimates */

NOTE: The data set WORK.ESTIMATES has 3 observations and 9 variables.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.04 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 2572.53k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 51 Switch Count 2
Page Faults 0
Page Reclaims 517
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272

90 data estimates;

91 set estimates;
92 keep ret_x ret_y ret_z;
93 /* Copula simulation */

NOTE: There were 3 observations read from the data set WORK.ESTIMATES.
NOTE: The data set WORK.ESTIMATES has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 801.06k
OS Memory 30124.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 52 Switch Count 2
Page Faults 0
Page Reclaims 143
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264

94 proc copula;

95 var ret_x ret_y ret_z;
96 define cop normal (cor = estimates);
___
1
WARNING 1-322: Assuming the symbol CORR was misspelled as cor.
97 simulate cop / ndraws = 500
98 outuniform = simulated_uniforms
99 plots=(data=uniform scatter);
____
22
202
ERROR 22-322: Syntax error, expecting one of the following: ), DATATYPE, DISTRIBUTION, NONE.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
100 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SIMULATED_UNIFORMS may be incomplete. When this step was stopped there were 0 observations and 0
variables.
WARNING: Data set WORK.SIMULATED_UNIFORMS was not replaced because this step was stopped.
NOTE: PROCEDURE COPULA used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 339.25k
OS Memory 29864.00k
Timestamp 03/30/2018 10:48:35 AM
Step Count 53 Switch Count 0
Page Faults 0
Page Reclaims 52
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16

101
102
103 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
115
Please help me to solve this and help me to add same data using excel sheet.
ballardw
Super User

Multiple identical posts merged to a single topic.

sreenu
Calcite | Level 5

Sorry for the mistake Sir ...thanks a lot for replying ....expecting good answers from the people like you 

Rick_SAS
SAS Super FREQ

You didn't mention what version of SAS you are running, but here is a link to the most recent doc.

1. The correct syntax for the DEFINE statement is 

     define cop normal (corr = estimates);

2. The correct syntax for the PLOTS option is

    plots=(datatype=uniform);

 

If you are using an older version of SAS that might have different syntax, consult the documentation for your version.

sreenu
Calcite | Level 5
data returns;
input ret_x ret_y ret_z;
cards;
0.004182 0.003503 0.584
-0.027960 -0.000582 0.54
0.006732 0.025611 0.14
-0.033435 -0.002838 -0.24
0.029560 0.010814 -0.4
-0.003054 -0.001689 0.8
-0.012255 -0.012408 0.9
0.013958 0.003427 0.14
-0.011318 -0.017075 0.14
-0.022587 0.002316 0.28
;
/* Copula estimation and simulation of returns */
proc copula data = returns;
var ret_x ret_y ret_z;
* fit T-copula to stock returns;
fit T /
marginals = empirical
method = MLE
plots = (datatype = both);
* simulate 10000 observations;
* independent in time, dependent in cross-section;
simulate /
ndraws = 10000
seed = 1234
out = simulated_returns
plots(unpack) = (datatype = original);

/* compute equally weighted portfolio return */
data port_ret (drop = i ret);
set simulated_returns;
array returns{3} ret_x ret_y ret_z;
ret =0;
do i =1 to 3;
ret = ret+ 0.2*exp(returns[i]);
end;
port_ret = ret-1;
/* compute descriptive statistics */
/* quantile table will give Value-at-Risk estimates for the portfolio */
proc univariate data = port_ret;
var port_ret;
run;

I have used this code in SAS o demand of academics. its working and got results...Stil I am having one problem..I didnt get a combined JPDF..what i have to do for that
sreenu
Calcite | Level 5

Dear sir,  I have got the following results, but i am expecting a JPDF table, How to get that jpdf

sreenu
Calcite | Level 5
Thanks for your reply sir .. am using Sas on demand of academics ....can i use the syntax suggested by you ?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2668 views
  • 0 likes
  • 3 in conversation