You are on page 1of 3

libname ADT "C:\Documents and Settings\tarun.

khanna\Desktop\SAS Project";
data ADT._first3000_withdupkey_2009;
set ADT._first3000_withdupkey;
if Temp_Year eq 2009 then output;
run;
proc print data=ADT._first3000_withdupkey_2009(obs=30);
var Temp_Year;
run;
/*keeping all the variable*/
data ADT._first3000_withdupkey_2009_keep;
set ADT._first3000_withdupkey_2009(keep=PropID
AGM_Individual_ID
AGM_Group_ID
Brand
Guest_FirstName
Guest_LastName
Guest_Address1
Guest_Address2
Guest_City
Guest_State
Guest_Zip
Guest_Country
Guest_Phone
Guest_CompanyNum
Company_Name
NationalCompany
Arrival
Departure
Adults
Child
Revenue
LOS
ADR
EMAIL
DISTRIBUTION_CHANNEL
Temp_Year);
run;
proc contents data=ADT._first3000_withdupkey_2009_keep;
run;
/* Sytaxes for final computing*/

data ADT._001_2009_brand1;
set ADT._first3000_withdupkey_2009_keep;
if Brand eq "ESD" then output;
run;
proc freq data=ADT._001_2009_brand1;
tables Brand Temp_Year;
run;
/* Syntax for First Attribute that is Customer Name*/
/* Syntax for Second Attribute that is Unique ID*/
/* Syntax for Third Attribute that is Type Of trips*/
/* Syntax for Fourth Attribute that is Type Of Account*/
data ADT._002_2009_brand1;
set ADT._001_2009_brand1;
Customer_Name=catx(' ',Guest_FirstName,Guest_LastName);
User_ID=cat(AGM_Group_ID,AGM_Individual_ID);
if Company_name IN ("vacation","leisure", "personal", "relocation") then No_trip
s_personal=1;
else if Company_name ~IN ("vacation","leisure", "personal", "relocation"," ") th
en No_trips_business=1;
else No_trips_unspec=1;
if NationalCompany eq "YES" then No_trips_NAcc=1;
else No_trips_NAcc=2;
run;
/* Syntax for Number of stays,average stay, total nights, Count of Distict distr
ibution Channel*/
proc sql;
create table ADT._003_2009_brand1 as
select count(User_ID) as _No_of_stays, avg(LOS) as _Avg_len_stay, sum(LOS) as _t
ot_ngt, count(distinct DISTRIBUTION_CHANNEL) as Temp, avg(ADR) as _avg_adr,sum(R
evenue) as _tot_rev,avg(Revenue) as avg_rev, User_ID,*
from ADT._004_2009_brand1
group by User_ID;
quit;
/*Creating five bucket variable for night, Distribution Chaneel and Sub Categori
sation*/
data ADT._004_2009_brand1;
set ADT._003_2009_brand1;
if _tot_ngt in (1,2) then _1_2_ngt=1;
else if _tot_ngt in (3,4,5,6 ) then _3_6_ngt=1;
else if _tot_ngt in (7,8,9,10,11,12,13,14) then _7_14_ngt=1;
else if _tot_ngt in (15,16,17,18,19,20,21,22,23,24,25,26,27,28,29) then _15_29_n
gt=1;
else if _tot_ngt >=30 then _30_ngt=1;
if Temp >1 then _DIST_CH = "Multiple";
if DISTRIBUTION_CHANNEL eq "Call center" then _DIST_CH_CC="Call center";
else if DISTRIBUTION_CHANNEL eq "GDS" then _DIST_CH_GDS="GDS";
else if DISTRIBUTION_CHANNEL eq "Internet" then _DIST_CH_I="Internet";
else if DISTRIBUTION_CHANNEL eq "Property Direct" then _DIST_CH_PD="Property Dir
ect";
if _avg_adr<40 then _avg_adr_lt40=1;
else if _avg_adr>39 and _avg_adr<70 then _avg_adr_40_69=1;
else if _avg_adr>69 and _avg_adr<100 then _avg_adr_70_99=1;
else if _avg_adr>99 and _avg_adr<130 then _avg_adr_100_129=1;
else if _avg_adr>=130 then _avg_adr_gt130=1;
if adults>1 then _tra_wth_ad="Y";
else _tra_wth_ad="N";
if child>0 then _tra_wth_chd="Y";
else _tra_wth_chd="N";
run;
Proc SQL ;
Create Table ADT._006_2009_brand1 As
Select JULDATE(arrival) as Jul,*
From ADT._004_2009_brand1
Group by User_ID ;
Quit ;
proc sort data=ADT._006_2009_brand1 out=ADT._007_2009_brand1;
by User_ID descending Jul;
run;
Proc SQL ;
Create Table ADT._008_2009_brand1 As
Select Guest_Address1, Guest_Address2, Guest_City,Guest_State,Guest_Zip,Guest_Co
untry,Guest_Phone,*
From ADT._007_2009_brand1
Group by User_ID
having Jul=max(Jul);
Quit ;
data ADT._009_2009_brand1;
set ADT._008_2009_brand1;
run;
PROC EXPORT DATA=ADT._009_2009_brand1
FILE="C:\Documents and Settings\tarun.khanna\Desktop\SAS Project\cus
tomer.sav"
DBMS=SPSS REPLACE;
RUN;
proc sort DATA=ADT._009_2009_brand1 out=ADT._010_2009_brand1 nodupkey;
run;

You might also like