Coder Social home page Coder Social logo

procsurvey's Introduction

marketing campaigns

proc surveyselect

step1 %var_check code /* create dataset for campaign 1 same number of observaions (n=2000) or count as campaing 2 and same respone rate */ proc surveyselect data=campaign1 (where (DV=1) method=srs n=2000 seed = 12345 out= dv1_campaign1; run;

proc surveyselect data=campaign1 (where (DV=0) method n=646380 seed = 12345 out=dv0_campaing1; run;

data campaign1; set dv1_campaign1 set dv0_campaign1; run;

STEP 2 โ€“ PROC LOGISTIC and ODS Output

%macro var_check(var)

/* simple logisitic on campaign 1 */ proc logistic data=campaign1 desc; model DV=&var / STB PARMLABEL;

/*ODS ouptut for campaign 1 */ ods output parameterestimates=est_campaign1 (keep = Variable Estimate StdErr /keeping 3 variables only/ rename = (Estimate=Est_Campaign1 StdErr=StdErr_campaign1)); run;

/* simple logisitic on campaign 2 */
proc logistic data=campaign2 desc; model DV=&var / STB PARMLABEL;

/*ODS ouptut for campaign 2 */ ods output parameterestimates=est_campaign2 (keep = Variable Estimate StdErr /keeping 3 variables only/ rename = (Estimate=Est_Campaign2 StdErr=StdErr_campaign2)); run;

STEP 3 โ€“ Merge the two ODS output datasets and create one dataset for each independent variable using Proc SQL

data &var._campaing1; set est_campaing1; if Variable = 'Intercept' then delete; run;

data &var._campaing2; set est_campaing2; if Variable = 'Intercept' then delete; run;

proc sql; create table &var._cl_2 as select a.variable as Variable length = 15, a.Est_campaign1, b.Est_campaign2, a.StdErr_campaign1, b.StdErr_campaign2&var from &var._campaign1 as a, &var._campaing2 as b where a.Variable = b.Variable; run;

/* 2-tailed t-test on campaign 1 & 2 coefficients */

data &var._cl_2; set &var._cl_2;

z = (Abs(Est_campaign2 - Est_campaign1))/Sqrt(StdErr_campaign12 + StdErr_campaign22); pvalue = 2 * (1 - cdf('normal', Z, 0, 1)); /* 2-tailed test */ if 0 < Pvalue < 0.1 then Sig_Flag_at_90=1; else if Pvalue="" then Sig_Flag_at_90=.; else Sig_Flag_at_90=0; if 0 < Pvalue < 0.05 then Sig_Flag_at_95=1; else if Pvalue="" then Sig_Flag_at_95=.; else Sig_Flag_at_95=0; if 0 < Pvalue < 0.01 then Sig_Flag_at_99=1; else if Pvalue="" then Sig_Flag_at_99=.; else Sig_Flag_at_99=0; run;

%mend;

proc contents data=campaing1 out=campaign1_contents norpint; run;

DATA NULL; SET campaign1_contents(where = (name not in ('/* Space to add not needed in the analysis IDs, Keys, etc.'))); Var_Check = '%Var_Check(' !! TRIM(LEFT(name)) !! ');'; CALL EXECUTE(Var_Check); run;

proc sql no print; select cats(name,"_cl_2") into :set_datasets separated by ' ' from campaign1_contents(where (name not in ('/* Space to add not needed in the analysis IDs, Keys, etc.'))); quit;

data dt.var_check_by_cmpn; set &set_datasets.; run;

ods html file = "var_check_by_cmpn.xls" style = minimal; proc print data = var_check_by_cmpn; run;

ods html close;

procsurvey's People

Contributors

rtawasha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.