BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Have 51 separate county datasets. Want to combine the 51 county datasets and create a variable "county name" based on the name of each dataset. Any suggestions?
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
You could "macro-ize" something like the program example below. It is always best, however to start with a basic non-macro program and understand how it works before you convert it to a macro program.

cynthia
[pre]
data new;
set sashelp.prdsale(in=prdsale)
sashelp.prdsal2(in=prdsal2)
sashelp.prdsal3(in=prdsal3);
if prdsale=1 then filename = 'SASHELP.PRDSALE';
else if prdsal2 = 1 then filename = 'SASHELP.PRDSAL2';
else if prdsal3 = 1 then filename = 'SASHELP.PRDSAL3';
run;

ods listing;
proc freq data=new order=data;
tables filename;
run;
[/pre]
Peter_C
Rhodochrosite | Level 12
if you have SAS92 use option INDSNAME= {VARname} see http://support.sas.com/kb/34/513.html .
Cynthia_sas
SAS Super FREQ
Thanks, Peter! I forget sometimes to point out the newer syntax.
cynthia

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
  • 3 replies
  • 711 views
  • 0 likes
  • 3 in conversation