Hello,
I used the codes at below to estimate the propensity score and logistic regression for inverse probability weighting.
How can I test the balance of the standardised mean differences before and after adjustment?
How to obtain the synthetic n values derived from weights?
Thanks
/***CREATING PROPENSITY SCORES********/
proc sort data=tab_imput; by _imputation_;run;
proc logistic data=tab_imput desc;
class var1 var2 var3 var4 var5 var6 var7 var8 var9 ;
model mut= var var1 var2 var3 var4 var5 var6 var7 var8 var9/link=logit rsquare ;
output out=denom p=d;
by _imputation_;
run;
proc logistic data=tab_imput desc;
model mut=;
output out=num p=n;
by _imputation_;
run;
proc sort data=tab_imput ;
by anonymat;run;
proc sort data=denom;
by anonymat;run;
proc sort data=num;
by anonymat;run;
data tab_imput_pscore;
merge tab_imput denom num;
by anonymat;
if mut=1 then uw=1/d; else if mut=0 then uw=1/(1-d);
if mut=1 then sw=n/d; else if mut=0 then sw=(1-n)/(1-d);
run;
proc sort data=tab_imput_pscore; by _imputation_;run;
/***PROPENSITY SCORE WEIGHTED OUTCOME MODEL****/
ods graphics on;
proc logistic data=tab_imput_pscore desc;
class mut(ref='no') / param=reference ;
model vif (event='no') = mut/ rsquare clodds=wald lackfit ;
weight sw ;
by _imputation_;
oddsratio mut;
ods output parameterEstimates = ipw_mut ;
run;
ods graphics off;
proc mianalyze parms=ipw_mut ;
modeleffects mut;
ods output parameterEstimates = ipw_mut1;
run;
data ipw_mut2; set ipw_mut1;
OR_est=EXP(ESTIMATE);
LCI_OR=OR_est*EXP(-1.96*STDERR);
UCI_OR=OR_est*EXP(+1.96*STDERR);
run;
proc print data=ipw_mut2;
var Parm OR_est LCI_OR UCI_OR Probt ;
run;
... View more
When using function foptname and filename contains Chinese character, it failed to return value. The prerequisites are:
1. Windows OS;
2. SAS 9.4 M8;
3. UTF-8 encoded SAS session;
And the active code page of my Windows OS is 936, which means simplified Chinese, a friend think this could be related.
Using foptname and finfo to get file attributes, with English file name:
filename _dummy_ "C:\Profiles\Work\temp\hello.sas";
data _null_;
fid=fopen('_dummy_');
if fid then do;
do i=1 to foptnum(fid);
foptname=foptname(fid,i);
finfo=finfo(fid,foptname);
put foptname ":" finfo;
end;
fid=fclose(fid);
end;
run;
Log:
文件名 :C:\Profiles\Work\temp\hello.sas
RECFM :V
LRECL :32767
文件大小(字节) :634
上次修改时间 :2024年05月16日 10时06分17秒
创建时间 :2024年05月16日 10时06分17秒
The output is cool.
With Chinese file name:
filename _dummy_ "C:\Profiles\Work\temp\你好.sas";
data _null_;
fid=fopen('_dummy_');
if fid then do;
do i=1 to foptnum(fid);
foptname=foptname(fid,i);
finfo=finfo(fid,foptname);
put foptname ":" finfo;
end;
fid=fclose(fid);
end;
run;
Log:
文件名 :C:\Profiles\Work\temp\你好.sas
RECFM :V
LRECL :32767
:
:
:
Missing the last 3 output.
With Janpenese file name:
filename _dummy_ "C:\Profiles\Work\temp\こんにちは.sas";
data _null_;
fid=fopen('_dummy_');
if fid then do;
do i=1 to foptnum(fid);
foptname=foptname(fid,i);
finfo=finfo(fid,foptname);
put foptname ":" finfo;
end;
fid=fclose(fid);
end;
run;
Log:
文件名 :C:\Profiles\Work\temp\こんにちは.sas
RECFM :V
LRECL :32767
:
:
:
Missing the last 3 output.
Why I cann't get right output when filename contains MBCS? Is there a robust way to get file attributes regardless of the encoding or OS? Thanks in advance.
PS1: Under euc-cn(whichc means simplified Chinese) encoded SAS session, Windows OS, the problem just disappear.
PS2: Under utf-8 encoded SAS session, Linux OS, the problem just disappear.
... View more
Dear All, I was trying to look for references on how to convert SAS script to PMML format but unsuccessful hence I posted here. The SAS script looks like below. The sample below is when PMML script is converted to SAS using proc pscore. Now, I want to know if there is a way if SAS to PMML. Thank you. length "a_segment"n $57 ; length "a_segment_new"n $62 ; "PSCR_TEMP_FINAL_PRED_VAR"n = 0; if ( "cohort"n eq 'AAA' ) then do; if ( missing( "a_score_id"n ) or missing( "a_score"n ) or ( ( "a_score_id"n ne 'XXX' ) & ( "a_score_id"n ne 'YYY' ) ) ) then do; "a_segment"n = 'SEG_A'; end; end; ... else if("a_segment"n eq 'SEG_A') then "a_segment"n = 'SEG_A' ; else if("a_segment"n eq 'SEG_B') then "a_segment"n = 'SEG_B' ; PSCR_EXIT : drop "PSCR_TEMP_FINAL_PRED_VAR"n "PSCR_ATTRIBUTE_MATCH"n;
... View more