Thanks so much Tom, arggh! The most elementary syntax brought me down. It worked with the example I provided. If you're still interested in this example, there are 3 other items I'd like to understand with this example. 1. The new datasets are ending up in my SAS WORK library instead of COED. I'm not sure where in this code to redirect the outputs to COED. 2. When I run it on my larger dataset and I have as values for type, strings that contain numbers (actually county FIPS codes), it won't work, and I do have them assigned as characters. They are 6 characters in length and look like, 000001, 000003, 000005...000135. 64 LIBNAME COED '\\Dwdufs2\leeju$\EDS\COED'; NOTE: Libref COED was successfully assigned as follows: Engine: V9 Physical Name: \\Dwdufs2\leeju$\EDS\COED 65 /* Step 1: separate each county (by the 'area' variable) into a separate table in order to 65 ! merge match them 66 in a horizontal format rather than the EDS format of vertical. */ 67 68 proc sql; 69 select count(distinct cfips) 70 into :n 71 from COED.counties_cleanup; NOTE: Writing HTML Body file: sashtml3.htm 72 select distinct cfips 73 into :cfips1 - :cfips%left(&n) 74 from COED.counties_cleanup; 75 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.43 seconds cpu time 0.04 seconds 76 options spool; 77 %macro makeds; 78 %do i=1 %to &n; 79 data &&cfips&i; 80 drop cfips; 81 set COED.counties_cleanup; 82 if cfips="&&cfips&i"; 83 run; 84 %end; 85 %mend makeds; 86 %makeds NOTE: Line generated by the macro variable "CFIPS1". 1 000001 ------ 22 200 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.DATA1 may be incomplete. When this step was stopped there were 0 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 3.When I switch it to the county name, it does work, but it uses the county names up to the first space. So if the county is 'ST. CROIX', it takes only 'ST'. And if the county is 'Fond du Lac', only 'Fond' is returned, and this creates processing errors too. Quite fussy macro, and wondering if Perl is more up to the task. NOTE: There were 12841 observations read from the data set COED.COUNTIES_CLEANUP. NOTE: The data set WORK.SHEBOYGAN has 332 observations and 4 variables. NOTE: The data set WORK.COUNTY has 332 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds This is for the county name ST. CROIX: ERROR: Libname ST is not assigned. NOTE: The SAS System stopped processing this step because of errors. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds Thanks, Judy
... View more