What exactly are you trying to understand? SAS developers don't use the term "Low code commands". All the %DO, %TO, and %END and &&&'s are part of the macro facility, which only generates text, in this case more SAS code. Looks like the program loops through 2 PROC SQL's I times (15 user input), and loops through several variables J times. It's easier to see if you indent it. Is this helpful? MACRO PREDICTSCORE(USRCNT=15);
%DO I = 1 %TO &USRCNT;
PROC SQL;
CREATE TABLE USERUSERPREDICTION&I AS
SELECT BUSINESS_ID, USER_ID, &&RU&I AS RU,
"&&USER&I" AS USER, CASE USER_ID
%DO J = 1 %TO &&NCNT_&I;
WHEN "&&&&NNAME&I._&J." THEN
&&&&NEIGHBOR&I._&J. * (STARS - &&RN_&I._&J)
%END;
END AS WEIGHTEDSCORE,
CASE USER_ID
%DO J=1 %TO &&NCNT_&I;
WHEN "&&&&NNAME&I._&J." THEN &&NEIGHBOR&I._&J.
%END;
END AS W
FROM YELP.USER_PROFILE_V1 WHERE
USER_ID IN (
%DO J = 1 %TO &&NCNT_&I;
"&&&NNAME&I._&J" %IF &J<&USRCNT
%THEN ,;
%END;
);
QUIT;
PROC SQL OUTOBS=10;
SELECT BUSINESS_ID, SUM(WEIGHTEDSCORE)/SUM(W) + RU AS PREDSCORE
FROM USERUSERPREDICTION&I GROUP BY BUSINESS_ID, RU ORDER BY PREDSCORE DESC ;
QUIT;
%END;
%MEND;
%PREDICTSCORE();
... View more