- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
I'm trying to to additive interaction to report RERI, RI, AP, S
these are the codings that I found but it didn't work
I changed it to surveylogistic to add weights
data _Temp1.mydata; set _Temp1.doc1;
run;
proc surveylogistic descending data=_Temp1.mydata outest=_Temp1.myoutput covout;
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
class Visit (ref = "2") agegrp (ref = "1") sex(ref = "2")Race (ref = "2")
educ (ref = "3") marit (ref = "1") / param = ref;
model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
WEIGHT weight4;
run;
data _Temp1.rerioutput;
set _Temp1.myoutput;
array mm {*} _numeric_;
b0=lag4(mm[1]);
b1=lag4(mm[2]);
b2=lag4(mm[3]);
b3=lag4(mm[4]);
v11=lag2(mm[2]);
v12=lag(mm[2]);
v13=mm[2];
v22=lag(mm[3]);
v23=mm[3];
v33=mm[4];
k1=exp(b1+b2+b3)-exp(b1);
k2=exp(b1+b2+b3)-exp(b2);
k3=exp(b1+b2+b3);
vreri=v11*k1*k1+v22*k2*k2+ v33*k3*k3+2*v12*k1*k2+2*v13*k1*k3
+ 2*v23*k2*k3;
reri=exp(b1+b2+b3)-exp(b1)-exp(b2)+1;
se_reri=sqrt(vreri);
ci95_l=reri-1.96*se_reri;
ci95_u=reri+1.96*se_reri;
keep reri se_reri ci95_l ci95_u;
if _n_=5;
run;
proc print data=_Temp1.rerioutput;
var reri se_reri ci95_l ci95_u;
run;
I got these errors:
NOTE: Invalid argument to function SQRT(-0.016074955) at line 88 column 4
Thank you!!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc surveylogistic data=_temp1.mydata;
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
class Visit (ref="2") agegrp (ref="1") sex(ref="2")Race (ref="2")
educ (ref="3") marit (ref="1") / param=ref;
model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
WEIGHT weight4;
output out=_temp1.regOut1;
run;
This should get you started. The data step after will not work but I have no idea what it's doing and suspect it's not right for what you're doing either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you're too lazy to format it yourself, you can highlight your code and then press CTRL+I in SAS EG or click the code format button in SAS Studio.
It also helps if you post your full log and code, in the log/code boxes which will maintain your format/alignment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your comment.
Here are the formatted code
data _Temp1.mydata;
set _Temp1.doc1;
run;
proc surveylogistic descending data=_temp1.mydata;
outset=_Temp1.myoutput covout;
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
class Visit (ref="2") agegrp (ref="1") sex(ref="2")Race (ref="2")
educ (ref="3") marit (ref="1") / param=ref;
model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
WEIGHT weight4;
run;
data _Temp1.rerioutput;
set _Temp1.myoutput;
array mm {*} _numeric_;
b0=lag4(mm[1]);
b1=lag4(mm[2]);
b2=lag4(mm[3]);
b3=lag4(mm[4]);
v11=lag2(mm[2]);
v12=lag(mm[2]);
v13=mm[2];
v22=lag(mm[3]);
v23=mm[3];
v33=mm[4];
k1=exp(b1+b2+b3)-exp(b1);
k2=exp(b1+b2+b3)-exp(b2);
k3=exp(b1+b2+b3);
vreri=v11*k1*k1+v22*k2*k2+ v33*k3*k3+2*v12*k1*k2+2*v13*k1*k3 + 2*v23*k2*k3;
reri=exp(b1+b2+b3)-exp(b1)-exp(b2)+1;
se_reri=sqrt(vreri);
ci95_l=reri-1.96*se_reri;
ci95_u=reri+1.96*se_reri;
keep reri se_reri ci95_l ci95_u;
if _n_=5;
run;
proc print data=_Temp1.rerioutput;
var reri se_reri ci95_l ci95_u;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is the log
NOTE: This session is in interactive mode.
NOTE: PROCEDURE SURVEYLOGISTIC used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 193.00k
OS Memory 22180.00k
Timestamp 06/24/2021 08:39:38 PM
Step Count 20 Switch Count 0
Page Faults 0
Page Reclaims 89
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
ERROR: Libref _TEMP1 is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
1 proc surveylogistic descending data=_temp1.mydata;
__________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, DATA, IN, INEST, MAXRESPONSELEVELS, METHOD, MISSING, N,
NAMELEN, NOMCAR, NOSORT, ORDER, R, VARMETHOD.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
2 outset=_Temp1.myoutput covout;
3 STRATA SDMVSTRA;
4 CLUSTER SDMVPSU;
5 class Visit (ref="2") agegrp (ref="1") sex(ref="2")Race (ref="2")
6 educ (ref="3") marit (ref="1") / param=ref;
7 model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
8 WEIGHT weight4;
9 run;
10
11 data _Temp1.rerioutput;
12 set _Temp1.myoutput;
ERROR: Libref _TEMP1 is not assigned.
13 array mm {*} _numeric_;
WARNING: Defining an array with zero elements.
14 b0=lag4(mm[1]);
15 b1=lag4(mm[2]);
16 b2=lag4(mm[3]);
17 b3=lag4(mm[4]);
18 v11=lag2(mm[2]);
19 v12=lag(mm[2]);
20 v13=mm[2];
21 v22=lag(mm[3]);
22 v23=mm[3];
23 v33=mm[4];
24 k1=exp(b1+b2+b3)-exp(b1);
25 k2=exp(b1+b2+b3)-exp(b2);
26 k3=exp(b1+b2+b3);
27 vreri=v11*k1*k1+v22*k2*k2+ v33*k3*k3+2*v12*k1*k2+2*v13*k1*k3 + 2*v23*k2*k3;
28 reri=exp(b1+b2+b3)-exp(b1)-exp(b2)+1;
29 se_reri=sqrt(vreri);
30 ci95_l=reri-1.96*se_reri;
31 ci95_u=reri+1.96*se_reri;
32 keep reri se_reri ci95_l ci95_u;
33
34 if _n_=5;
35 run;
ERROR: Libref _TEMP1 is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
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 345.96k
OS Memory 22180.00k
Timestamp 06/24/2021 08:39:38 PM
Step Count 21 Switch Count 0
Page Faults 0
Page Reclaims 59
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
36
37 proc print data=_Temp1.rerioutput;
ERROR: Libref _TEMP1 is not assigned.
38 var reri se_reri ci95_l ci95_u;
39 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 74.87k
OS Memory 22436.00k
Timestamp 06/24/2021 08:39:38 PM
Step Count 22 Switch Count 0
Page Faults 0
Page Reclaims 83
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
40
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Library not assigned. So none of those data sets in _Temp1 are available. Need a Libname before using them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You should post log entries by copying the text from the log and then pasting into a text box opened on the forum using the </> icon. The message windows reformat text and moved the underscore that would appear under the place where SAS found something objectionable.
DESCENDING is not an option that I see for the Proc Surveylogistic statemen. There is an ORDER= option bu tit doesn't accept Descending. Neither is OUTEST= and option. Documentation: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_surveylogistic_syntax01.htm
The Output statement may get the output you want, or use ODS OUTPUT to select specific table information to be saved in a data set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I got the code from this paper
https://www.degruyter.com/document/doi/10.1515/em-2013-0005/html
Section: SAS code for additive interaction for binary exposures
They provided proc logisitic but my data has weights so I tried surveylogistics but it didn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Where's your libname declaration?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have fixed the libname issue.
I still got these errors. I'm wondering if anyone have additive interaction code that works with weights?
Thanks!!
448 data _Temp1.mydata;
449 set _Temp1.doc1;
450 run;
NOTE: There were 19225 observations read from the data set _TEMP1.DOC1.
NOTE: The data set _TEMP1.MYDATA has 19225 observations and 81 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
user cpu time 0.00 seconds
system cpu time 0.03 seconds
memory 3724.21k
OS Memory 62388.00k
Timestamp 06/24/2021 09:05:42 PM
Step Count 290 Switch Count 3
Page Faults 0
Page Reclaims 534
Page Swaps 0
Voluntary Context Switches 206
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 24584
451
NOTE: PROCEDURE SURVEYLOGISTIC used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1674.84k
OS Memory 60336.00k
Timestamp 06/24/2021 09:05:42 PM
Step Count 291 Switch Count 0
Page Faults 0
Page Reclaims 242
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 288
Block Output Operations 0
NOTE: The SAS System stopped processing this step because of errors.
452 proc surveylogistic descending data=_temp1.mydata;
__________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, DATA, IN, INEST, MAXRESPONSELEVELS, METHOD, MISSING, N,
NAMELEN, NOMCAR, NOSORT, ORDER, R, VARMETHOD.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
453 outset=_Temp1.myoutput covout;
454 STRATA SDMVSTRA;
455 CLUSTER SDMVPSU;
456 class Visit (ref="2") agegrp (ref="1") sex(ref="2")Race (ref="2")
457 educ (ref="3") marit (ref="1") / param=ref;
458 model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
459 WEIGHT weight4;
460 run;
461
462 data _Temp1.rerioutput;
463 set _Temp1.myoutput;
464 array mm {*} _numeric_;
465 b0=lag4(mm[1]);
466 b1=lag4(mm[2]);
467 b2=lag4(mm[3]);
468 b3=lag4(mm[4]);
469 v11=lag2(mm[2]);
470 v12=lag(mm[2]);
471 v13=mm[2];
472 v22=lag(mm[3]);
473 v23=mm[3];
474 v33=mm[4];
475 k1=exp(b1+b2+b3)-exp(b1);
476 k2=exp(b1+b2+b3)-exp(b2);
477 k3=exp(b1+b2+b3);
478 vreri=v11*k1*k1+v22*k2*k2+ v33*k3*k3+2*v12*k1*k2+2*v13*k1*k3 + 2*v23*k2*k3;
479 reri=exp(b1+b2+b3)-exp(b1)-exp(b2)+1;
480 se_reri=sqrt(vreri);
481 ci95_l=reri-1.96*se_reri;
482 ci95_u=reri+1.96*se_reri;
483 keep reri se_reri ci95_l ci95_u;
484
485 if _n_=5;
486 run;
NOTE: Invalid argument to function SQRT(-0.016074955) at line 480 column 10.
_LINK_=LOGIT _TYPE_=COV _STATUS_=0 Converged _NAME_=agegrp Intercept=-0.000215067 CATYPE=-0.000225321 mon=-0.000340954
CATYPEmon=0.0001398961 agegrp=0.0005607557 sex=0.000076247 educ=0.0001019548 marit=-0.000390403 race=-9.495861E-7
_LNLIKE_=-5769.4632 _ESTTYPE_=MLE b0=3.2380054044 b1=-1.650942484 b2=-0.661945211 b3=0.3391765085 v11=0.339076178 v12=-0.177919102
v13=-0.000225321 v22=-0.070167514 v23=-0.000340954 v33=0.0001398961 k1=-0.052928725 k2=-0.376906662 k3=0.138940265
vreri=-0.016074955 reri=0.4312243482 se_reri=. ci95_l=. ci95_u=. _ERROR_=1 _N_=6
NOTE: Invalid argument to function SQRT(-0.027224332) at line 480 column 10.
_LINK_=LOGIT _TYPE_=COV _STATUS_=0 Converged _NAME_=sex Intercept=-0.005095306 CATYPE=0.000746044 mon=0.0005036479
CATYPEmon=-0.000157906 agegrp=0.000076247 sex=0.0020036536 educ=-0.000051557 marit=-0.000212716 race=0.0000135271
_LNLIKE_=-5769.4632 _ESTTYPE_=MLE b0=-1.650942484 b1=0.865337139 b2=0.339076178 b3=-0.177919102 v11=-0.177919102 v12=-0.000225321
v13=0.000746044 v22=-0.000340954 v23=0.0005036479 v33=-0.000157906 k1=0.4154561657 k2=1.3876128252 k3=2.7912630937
vreri=-0.027224332 reri=0.0118058972 se_reri=. ci95_l=. ci95_u=. _ERROR_=1 _N_=7
NOTE: Invalid argument to function SQRT(-0.000437039) at line 480 column 10.
_LINK_=LOGIT _TYPE_=COV _STATUS_=0 Converged _NAME_=educ Intercept=0.0009619728 CATYPE=-0.000539442 mon=-0.000674361
CATYPEmon=0.0001440399 agegrp=0.0001019548 sex=-0.000051557 educ=0.0008760086 marit=7.7140817E-6 race=-0.000123359
_LNLIKE_=-5769.4632 _ESTTYPE_=MLE b0=-0.661945211 b1=0.339076178 b2=0.1371383587 b3=-0.070167514 v11=-0.000225321 v12=0.000746044
v13=-0.000539442 v22=0.0005036479 v23=-0.000674361 v33=0.0001440399 k1=0.097222858 k2=0.3538862933 k3=1.5008731264
vreri=-0.000437039 reri=-0.049763975 se_reri=. ci95_l=. ci95_u=. _ERROR_=1 _N_=8
NOTE: Invalid argument to function SQRT(-0.000275743) at line 480 column 10.
_LINK_=LOGIT _TYPE_=COV _STATUS_=0 Converged _NAME_=marit Intercept=-0.003674134 CATYPE=0.0010595329 mon=0.0003864113
CATYPEmon=-0.000211588 agegrp=-0.000390403 sex=-0.000212716 educ=7.7140817E-6 marit=0.0014293246 race=0.0000496697
_LNLIKE_=-5769.4632 _ESTTYPE_=MLE b0=0.3391765085 b1=-0.177919102 b2=-0.070167514 b3=0.0368177487 v11=0.000746044 v12=-0.000539442
v13=0.0010595329 v22=-0.000674361 v23=0.0003864113 v33=-0.000211588 k1=-0.027453759 k2=-0.122681269 k3=0.8095563748
vreri=-0.000275743 reri=0.0403085972 se_reri=. ci95_l=. ci95_u=. _ERROR_=1 _N_=9
NOTE: Invalid argument to function SQRT(-0.000016069) at line 480 column 10.
_LINK_=LOGIT _TYPE_=COV _STATUS_=0 Converged _NAME_=race Intercept=-0.000929174 CATYPE=-4.453936E-6 mon=0.0000280497
CATYPEmon=-0.00001608 agegrp=-9.495861E-7 sex=0.0000135271 educ=-0.000123359 marit=0.0000496697 race=0.0004827838
_LNLIKE_=-5769.4632 _ESTTYPE_=MLE b0=-0.000215067 b1=-0.000225321 b2=-0.000340954 b3=0.0001398961 v11=-0.000539442 v12=0.0010595329
v13=-4.453936E-6 v22=0.0003864113 v23=0.0000280497 v33=-0.00001608 k1=-0.000200992 k2=-0.000085392 k3=0.9995737117
vreri=-0.000016069 reri=0.0001399034 se_reri=. ci95_l=. ci95_u=. _ERROR_=1 _N_=10
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
4 at 475:5 4 at 475:11 4 at 475:14 4 at 475:18 4 at 475:19 4 at 476:5 4 at 476:11 4 at 476:14 4 at 476:18
4 at 476:19 4 at 477:5 4 at 477:11 4 at 477:14 4 at 478:11 4 at 479:7 4 at 479:13 4 at 479:16 4 at 479:20
4 at 479:21 4 at 480:10 9 at 481:18 9 at 482:18
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
5 at 480:10
NOTE: There were 10 observations read from the data set _TEMP1.MYOUTPUT.
NOTE: The data set _TEMP1.RERIOUTPUT has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1081.96k
OS Memory 59828.00k
Timestamp 06/24/2021 09:05:42 PM
Step Count 292 Switch Count 2
Page Faults 0
Page Reclaims 126
Page Swaps 0
Voluntary Context Switches 53
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 280
487
488 proc print data=_Temp1.rerioutput;
489 var reri se_reri ci95_l ci95_u;
490 run;
NOTE: There were 1 observations read from the data set _TEMP1.RERIOUTPUT.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 625.65k
OS Memory 59568.00k
Timestamp 06/24/2021 09:05:42 PM
Step Count 293 Switch Count 0
Page Faults 0
Page Reclaims 60
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 288
Block Output Operations 16
491
492
493 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
505
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc surveylogistic data=_temp1.mydata;
STRATA SDMVSTRA;
CLUSTER SDMVPSU;
class Visit (ref="2") agegrp (ref="1") sex(ref="2")Race (ref="2")
educ (ref="3") marit (ref="1") / param=ref;
model visit=CATYPE mon CATYPE*mon agegrp sex educ marit race;
WEIGHT weight4;
output out=_temp1.regOut1;
run;
This should get you started. The data step after will not work but I have no idea what it's doing and suspect it's not right for what you're doing either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Still using the option Descending in Surveylogistic, which is not valid. So that Surveylogistic code is not running at all. That is what this statement means. So your data step is using some _Temp1.myoutput data set created elsewhere
NOTE: The SAS System stopped processing this step because of errors.
SAS doesn't deal with imaginary numbers like square root of -.02. So either the way you create the variable VRERI is incorrect or you should ensure the value is positive before taking the square root. How to deal with the missing values of se_reri is another story.