You are on page 1of 2

Proc import datafile="C:\Users\lab1.

IMTEDU\Desktop\Vazir\Data\SAS Assignment\Clo
thing_Store_28799.txt"
out = raw1
dbms = csv
replace;
getnames = yes;
run;

data clothing_store_Trans;
set raw1;
if PSSPEND<0 then delete;
/*else */
/*
If PSSPEND ne 0 then PSSPEND_log=log(PSSPEND);else */
/*
PSSPEND_log=0;*/
if SMONSPEND<0 then delete;
/*else */
/*If SMONSPEND ne 0 then SMONSPEND_log=log(SMONSPEND);else */
/*
SMONSPEND_log=0;*/
if PCOLLSPND<0 then delete;
keep HHKEY
FRE
CC_CARD PSSPEND SMONSPEND
HI
D
RESP;
run;

PCOLLSPN

Data Var_Transform;
Set clothing_store_Trans;
HI_Log = LOG(HI);
SQrt_FRE=sqrt(FRE);
SQrt_PSSPEND=sqrt(PSSPEND);
SQrt_SMONSPEND=sqrt(SMONSPEND);
SQrt_PCOLLSPND=sqrt(PCOLLSPND);
/*Setting FLags*/
IF
FRE<=0 then Flag_FRE= 0; Else Flag_FRE = 1;
if PSSPEND<=0 then Flag_PSSPEND= 0; Else Flag_PSSPEND= 1;
IF SMONSPEND<=0 then Flag_SMONSPEND= 0; Else Flag_SMONSPEND = 1 ;
IF HI<=0 then Flag_HI= 0; Else Flag_HI= 1;
IF PCOLLSPND<=0 then Flag_PCOLLSPND= 0; Else Flag_PCOLLSPND= 1;
DROP HI SMONSPEND PSSPEND FRE PCOLLSPND;
run;
/*Standardisation*/
Proc Standard Data=Var_Transform Mean=0 STD=1 Out=Var_Stndrd;
Var
HI_LOG
SQRT_:
;
Run;
/*Factor analysis*/
proc factor data = Var_Stndrd scree method = principal nfactors = 3 out=Var_Stnd
rd_factor;
Var
CC_CARD
HI_LOG
SQRT_:
FLAG_:
;
Run;

/*Training and Validation dataset creation*/


data temp;
set Var_Stndrd_factor ;
n=ranuni(8);
proc sort data=temp;
by n;
data training testing;
set temp nobs=nobs;
if _n_<=.7*nobs then output training;
else output testing;
run;
/*Logistic Regression for Training*/
Proc Logistic Data=training Descending outmodel=param_out_Train;
Model Resp = factor1 factor2 factor3 /selection=stepwise rsq ctable;
Output out=clothing_store_pred_Train p=phat;
Run;

/*Logistic Regression for Testing*/


Proc Logistic Data=Testing Descending outmodel=param_out_Test;
Model Resp = factor1 factor2 factor3 /selection=stepwise rsq ctable;
Output out=clothing_store_pred_Test p=phat;
Run;

You might also like