09-03-2016 03:53 PM
Hi, i met one macro problem, hope sas professional can give me a hand...thank you so much!
I wang to using macro and loop to do the proc export, TEMPEX.&TABLE is a data set created in sas, it will be export as multiple txt format file, and each txt file was exported based on some criterials like &TABLE(column value or name), &BRKEEP.="NOK", &DATA_ELEMENT_PAC.txt .
i didn't show the excel table i imported in sas, which is the WORK.TRANSPOSE, I will use excel table to select multiple column value as macro variable, and then do loop and use as parameter for the proc export. at begining records and max1 run well. but macro doesn't work. BR01 to BR10 are excel table column name, and will be input into &BRKEEP, then use as a criterial to do the proc export.
can anyone help me!! thank you PRO.
my email email@example.com
RECORDS = _N_;
SELECT MAX(RECORDS) AS MAX1
%Do I=1 %to &Max1;
PROC SQL Noprint;
Where RECORDS =&I;
%LET BRKEEP= &BR01 &BR02 &BR03 &BR04 &BR05 &BR06 &BR07 &BR08 &BR09 &BR10;
Data TEMPEX.&TABLE. (KEEP=CODENT CENTALTA CUENTNU CUENTA IDPROD CONPROD
FECALTA FECBAJA CDESTCTA POSITION BALANCE IMPRFAC_SIGNO LICRECTA
FINAL_CYCLE LICRERET CDESTCTA NUMULTXT NUEXTPEN FEULTEXT CCLAMON
CONPROD_FINAL CDCONECO VATRAFIN XPOTRAMO FECINI FECFIN NUMMOVEXT
IMPBRUECO DESCONECO &BRKEEP.);
PROC EXPORT DATA=TEMPEX.&TABLE. (WHERE=(&BRKEEP.="NOK" )) /*CARD0004 - Card Credit Limit*/
09-03-2016 04:09 PM
Your WHERE clause doesn't make sense.
To check it replace it with your macro variable value and see what it would resolve to.
PS do you know you can export a file using a data step to create multiple text files in one datastep? Having it all in data step logic may make it easier to debug.