BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

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);

1 REPLY 1
ballardw
Super User

%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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 818 views
  • 0 likes
  • 2 in conversation