Hello, I have a code which I need to iterate it over a list of values from a dataset. This is the list of sochen_id sitting in work.distinct_values table : PROC SQL;
CREATE TABLE WORK.DISTINCT_VALUES AS
SELECT DISTINCT SOCHEN_ID FROM WORK.SOCHEN_SALES_OUTPUT_STRUC_3;
QUIT; And this is the code which is working fine but I always need to put manually distinct value for var and run it. The problem is I have 1000 distinct values to put in the var variable so naturally I thinking on a loop here. %LET VAR = 75267;
OPTIONS MSGLEVEL=I;
FILENAME SRC "Data Analytics\Template.Xlsx" RECFM=N;
FILENAME DEST "Data Analytics\Sochen_&VAR..Xlsx" RECFM=N;
DATA _NULL_;
LENGTH MSG $ 384;
RC=FCOPY('SRC', 'DEST');
IF RC=0 THEN
PUT 'COPIED SRC TO DEST.';
ELSE DO;
MSG=SYSMSG();
PUT RC= MSG=;
END;
RUN;
PROC EXPORT DATA=WORK.SOCHEN&VAR.SALES
DBMS=XLSX
OUTFILE="Data Analytics\Sochen_&VAR..Xlsx"
REPLACE;
SHEET='SALES';
RUN;
PROC EXPORT DATA=WORK.SOCHEN&VAR.NOVIDEA
DBMS=XLSX
OUTFILE="\Data Analytics\Sochen_&VAR..xlsx"
REPLACE;
SHEET='NOVIDEA';
RUN;
How do I rap all this in a do loop which will loop on the list of sochen_id values from the work.distinct_values dataset?
... View more