proc imstat; table MYlasr.salesfact; 1 tableinfo / save = tabinf; store tabinf(1,3) = nObs; run; distinct / save = dtab; store dtab(1,2) = numItem; store dtab(2,2) = numUser; run; table MYlasr.salesfact; 2 compute joinkey "joinkey = &userID || &itemID;"; run; table MYlasr.salesfact(tempnames=(t1)); summary t1 / groupby=(&userID &itemID) temptable tn=t1 3 te="t1=1;" save=tabl; summary t1 / groupby=(&userID) temptable tn=t1 te="t1=1;" save=tab2; summary t1 / groupby=(&itemID) temptable tn=t1 te="t1=1;" save=tab3; run; store tab1(2,2) = freq_user_item; 4 store tab2(2,2) = freq_user; store tab3(2,2) = freq_item; run; table MYlasr.&freq_user_item; schema &freq_user(&userID=&userID / prefix=UserTotal,_n_) 5 &freq_item(&itemID=&itemID / prefix=ItemTotal,_n_) / mode=table; run; table MYlasr.&_templast_; 6 compute joinkey "joinkey = &userID || &itemID;"; run; table MYlasr.salesfact; schema &_templast_(joinkey=joinkey / prefix=r,_n_ UserTotal__N_ ItemTotal__N_); run; table MYlasr.&_templast_; compute Rating_iuf "Rating_iuf = log10(r__N_+1)*log10(&nObs/(r_ItemTotal__n_+1));"; run; compute Rating_iif "Rating_iif = log10(r__N+1)*log10(&nObs/(r_UserTotal__n_+1));"; run; compute Rating_simple "Rating_simple = Round((r__N_/r_UserTotal__n_)*10+1,1);"; run; table MYlasr.&_templast_; 7 save path="/hps/rating_tfidf" copies=1 replace fullpath; run;
proc recommend port=&lasrport recom = rs.DEPTSTORE; add rs.DEPTSTORE /item = item_sk user = household_sk 1 rating = &rating; addtable MYlasr.MBA_rating_tfidf / recom = rs.DEPTSTORE 2 type = rating vars=(item_sk household_sk &rating); addtable MYlasr.household / recom = rs.DEPTSTORE type = user; addtable MYlasr.item / recom = rs.DEPTSTORE type = item; run; method cluster / clusttech=kmeans numclus=50 dist=euc type=user 3 maxiter=10 label="clust" details terms=("Convenience", "Occasional", "Unk") tokens=(" ") noidf seed=1234 clustinfo clustvars=(LIFESTYLE_SEGMENT FAMILY PET); run; predict / users=("11815911") method=cluster label="clust" 4 Num = 5; run; method svd / factors = 20 label = "svd_1" fconv = 1e-3 gconv = 1e-3 5 maxiter = 100 seed = 12314 MAXFEVAL = 5000 function=L2 lamda = 0.2 technique = als; run; predict / method = svd label = "svd_1" Num = 5 6 users = ("11815911"); run; quit;