DATA Step, Macro, Functions and more

Macro: subset and export multiple tables to MS Access

Reply
Regular Contributor
Posts: 194

Macro: subset and export multiple tables to MS Access

G'day.  Appreciate any help you can give!

I'm trying to subset a dataset by county (i.e, create one table with just observations from Humboldt. Then, create another table with just observations from Fresno).Then export each county-specific dataset to a MS Access Database using a Macro.

I've not gotten very far.

%macro table(county=);

DATA Elig13<want countyname here>;

    set eligibles;

    if coname=<countyname here>;

run;

%mend;

%table (HUMBOLDT);

%TABLE (FRESNO);

%TABLE (ORANGE);

%TABLE (KERN);

Super User
Posts: 11,343

Re: Macro: subset and export multiple tables to MS Access

%macro table(county=);

DATA Elig13&county ;

     set eligibles;

    if upcase(coname)= upcase("&county"); /* using upcase so you don't have to worry about either mixed case in the data set for the variable or making the parameter county case match the value in the dataset*/

run;

%mend;

WARNING: If you have any county names with spaces in them then some additional code will be needed to make a valid data set name.

Ask a Question
Discussion stats
  • 1 reply
  • 260 views
  • 0 likes
  • 2 in conversation