Hi there,
I want to extract a subset of a dataset based on a specific input variable called "region".
Here's my code, but I don't know why it doesn't works.
%macro liste_region (region=);
%if ®ion. = "Abitibi-Témiscamingue" %then no_comte = "(1, 2, 101)" and out="AT";
FILENAME output "/folders/myfolders/&out..xlsx";
data work.membres_actifs_&out.;
set work.membres_actifs_circ;
where NoComteResidence in no_comte;
run;
data work.membres_anciens_&out. ;
set work.membres_anciens_circ;
where NoComteResidence in no_comte;
run;
proc export data=work.membres_actifs_&out.
outfile=output
dbms=xlsx replace;
sheet=membres_actifs;
run;
proc export data=work.membres_anciens_&out.
outfile=output
dbms=xlsx replace;
sheet=membres_anciens;
run;
%mend liste_region;
%liste_region(region="Abitibi-Témiscamingue");
It gives me the following error:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 %liste_region(region="Abitibi-Témiscamingue");
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 no_comte = "(1, 2, 101)" and out="AT"
________
180
WARNING: Apparent symbolic reference OUT not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 data work.membres_actifs_&out.(drop=ComteMembre Titre
_
22
200
73 ! DateNaissance Ehnie Langue M90 NoComteMembre NoComteResidence NoPLQ P90 P1AN Reg Section
73 ! Anciennete Cat:
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 cp_: ind: region_adm); set work.membres_actifs_circ; where NoComteResidence in no_comte; run;
________
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: (, :.
ERROR 76-322: Syntax error, statement will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MEMBRES_ACTIFS_ may be incomplete. When this step was stopped there were 0 observations and 18
variables.
WARNING: Data set WORK.MEMBRES_ACTIFS_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 data
73 ! work.membres_anciens_&out. (drop=ComteMembre Titre DateNaissance Ehnie Langue M90 NoComteMembre NoComteResidence NoPLQ
_
22
200
73 ! P90 P1AN Reg Section Anciennete
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MEMBRES_ANCIENS_ may be incomplete. When this step was stopped there were 0 observations and 18
variables.
WARNING: Data set WORK.MEMBRES_ANCIENS_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 Cat: cp_: ind: region_adm); set work.membres_actifs_circ; where NoComteResidence in no_comte; run;
________
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: (, :.
ERROR 76-322: Syntax error, statement will be ignored.
ERROR: The value ABITIBI-TÉMISCAMINGUE is not a valid SAS member name.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MEMBRES_ACTIFS_ may be incomplete. When this step was stopped there were 0 observations and 48
variables.
WARNING: Data set WORK.MEMBRES_ACTIFS_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
WARNING: Apparent symbolic reference OUT not resolved.
NOTE 137-205: Line generated by the invoked macro "LISTE_REGION".
73 Cat: cp_: ind: region_adm); set work.membres_actifs_circ; where NoComteResidence in no_comte; run; proc sort
73 ! data=work.membres_actifs_&out. ; by ComteResidence Nom Prenom; run; proc sort data=work.membres_anciens_&out. ; by
_
22
73 ! ComteResidence Nom Prenom;
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA, DATECOPY, DETAILS, DIAG, DUPOUT,
EBCDIC, EQUALS, FINNISH, FORCE, IN, ISA, L, LEAVE, LIST, MESSAGE, MSG, NATIONAL, NODUP, NODUPKEY, NODUPKEYS,
NODUPLICATE, NODUPLICATES, NODUPREC, NODUPRECS, NODUPS, NOEQUALS, NORWEGIAN, NOTHREADS, NOUNIKEY, NOUNIKEYS,
NOUNIQUEKEY, NOUNIQUEKEYS, NOUNIQUEREC, NOUNIQUERECS, NOUNIREC, NOUNIRECS, OSA, OUT, OVERWRITE, PAGESIZE, PRESORTED,
PSIZE, REVERSE, SIZE, SORTSEQ, SORTSIZE, SORTWKNO, SWEDISH, T, TAGSORT, TECH, TECHNIQUE, TESTHSI, THREADS, UNIOUT,
UNIQUEOUT, WKNO, WORKNO.
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 Cat: cp_: ind: region_adm); set work.membres_actifs_circ; where NoComteResidence in no_comte; run; proc sort
73 ! data=work.membres_actifs_&out. ; by ComteResidence Nom Prenom; run; proc sort data=work.membres_anciens_&out. ; by
_
200
73 ! ComteResidence Nom Prenom;
ERROR 200-322: The symbol is not recognized and will be ignored.
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference OUT not resolved.
22: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA, DATECOPY, DETAILS, DIAG, DUPOUT,
EBCDIC, EQUALS, FINNISH, FORCE, IN, ISA, L, LEAVE, LIST, MESSAGE, MSG, NATIONAL, NODUP, NODUPKEY, NODUPKEYS,
NODUPLICATE, NODUPLICATES, NODUPREC, NODUPRECS, NODUPS, NOEQUALS, NORWEGIAN, NOTHREADS, NOUNIKEY, NOUNIKEYS,
NOUNIQUEKEY, NOUNIQUEKEYS, NOUNIQUEREC, NOUNIQUERECS, NOUNIREC, NOUNIRECS, OSA, OUT, OVERWRITE, PAGESIZE, PRESORTED,
PSIZE, REVERSE, SIZE, SORTSEQ, SORTSIZE, SORTWKNO, SWEDISH, T, TAGSORT, TECH, TECHNIQUE, TESTHSI, THREADS, UNIOUT,
UNIQUEOUT, WKNO, WORKNO.
200: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 200-322: The symbol is not recognized and will be ignored.
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
WARNING: Apparent symbolic reference OUT not resolved.
NOTE 137-205: Line generated by the invoked macro "LISTE_REGION".
73 run; proc export data=work.membres_actifs_&out. outfile=output dbms=xlsx replace; sheet=membres_actifs; run; proc
_
22
73 ! export data=work.membres_anciens_&out. outfile=output dbms=xlsx replace; sheet=membres_anciens; run;
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE,
REPLACE, TABLE, _DEBUG_.
NOTE: Line generated by the invoked macro "LISTE_REGION".
73 run; proc export data=work.membres_actifs_&out. outfile=output dbms=xlsx replace; sheet=membres_actifs; run; proc
_
200
73 ! export data=work.membres_anciens_&out. outfile=output dbms=xlsx replace; sheet=membres_anciens; run;
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: Apparent symbolic reference OUT not resolved.
22: LINE and COLUMN cannot be determined.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE,
REPLACE, TABLE, _DEBUG_.
200: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 200-322: The symbol is not recognized and will be ignored.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
WARNING: Apparent symbolic reference OUT not resolved.
NOTE: The SAS System stopped processing this step because of errors.
74
75 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
... View more