Hello, I know this one is a tricky topic.. I got a macro that can output a macro variable that contain single quotes: %MACRO TRANSFORM_LIST_TO_QUOTED_LIST(LIST, OUTPUT_VAR, SEPERATOR=, QUOTE_CHAR=);
%IF ""E_CHAR." = "" %THEN %DO;
%LET QUOTE_CHAR = %NRSTR(%"); /* " closing quote for visual only */
%END;
%IF "&SEPERATOR." = "" %THEN %DO;
%LET SEPERATOR =%NRSTR( ); *default sep is a space ;
%END;
* structure the list as a list of column to keep into an SQL. ;
%INIT_VAR_AS_GLOBAL(&OUTPUT_VAR.);
* loop on each element of the list;
%DO I=1 %TO %SYSFUNC(COUNTW("&LIST."," ",));
%IF &I.=1 %THEN %DO;
%LET &OUTPUT_VAR. = "E_CHAR.%SCAN(&LIST., &I., " ")"E_CHAR.;
%END;
%ELSE %DO;
%LET &OUTPUT_VAR. = &&&OUTPUT_VAR..&SEPERATOR."E_CHAR.%SCAN(&LIST., &I., " ")"E_CHAR.;
%END;
%END;
%MEND TRANSFORM_LIST_TO_QUOTED_LIST; The macro is working fine.. and if I call it like this: %LET COLUMNS_TO_KEEP_B = Name Sex Age; %TRANSFORM_LIST_TO_QUOTED_LIST(LIST=&COLUMNS_TO_KEEP_B., OUTPUT_VAR=HASH_COLUMNS_TO_KEEP_B, SEPERATOR=%NRSTR(,), QUOTE_CHAR=%NRSTR(%')) the %PUT &HASH_COLUMNS_TO_KEEP_B.; function gives me 'Name', 'Sex', 'Age' but in the global variable table the results looks really different if I try to use it into my hash table : RC = H_MERGE.DEFINEDATA(&HASH_COLUMNS_TO_KEEP_B.); i'm getting this error: ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase. ERROR 386-185: Expecting an arithmetic expression. ERROR 76-322: Syntax error, statement will be ignored. If i manaully put the list like this the macro run fine. RC = H_MERGE.DEFINEDATA('Name', 'Sex', 'Age'); So it's really seem to be an issue with the macro that dynamically genrerate the string.. Any clue How I could solve this issue? Best regards, Samuel
... View more