Search code examples
sassas-macro

PROC DATASETS macro variable error


I am able to resolve the macro variable to the name I was expecting. But delete statement in the proc datasets is not getting recognized. How to make it work?

PROC DATASETS LIB=WORK NODETAILS NOLIST;
    DELETE  &INPUT._mi  &INPUT._lc ;
RUN;

MPRINT(GET_true_value):   PROC DATASETS LIB=WORK NODETAILS NOLIST;
NOTE: Line generated by the macro variable "INPUT".
108          work.true_value_mi
             __________________
             22
             201
MPRINT(GET_true_value):   DELETE work.true_value_mi work.true_value_lc ;
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
MPRINT(GET_true_value):   RUN;

ERROR 22-322: Expecting a name.  

ERROR 201-322: The option is not recognized and will be ignored.

NOTE: Statements not processed because of errors noted above.
109   

Solution

  • It looks like the problem is that the delete statement as written is including the library name. This is not required (and throws an error) because the library is specified on the PROC DATASETS statement.

    You want your macro variables to resolve to this:

    PROC DATASETS LIB=WORK NODETAILS NOLIST;
        DELETE true_value_mi ;
    RUN;