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
Diamond | Level 26
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
Diamond | Level 26
Thanks, Peter! I forget sometimes to point out the newer syntax.
cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1341 views
  • 0 likes
  • 3 in conversation