BookmarkSubscribeRSS Feed
juliajulia
Obsidian | Level 7

hello all sas experts:

 

i have a folder that stored a lot of datasets from different years. the dataset are: Cinfo2004 to Cinfo2021, Ginfo2006 to Ginfo2021, Ginfo_Geocode2010 to Ginfo_Geocode2021. 

I would like to create a sas code to list all data files in the directory by providing the earliest and latest years for each type of the dataset. for example Cinfo’s earliest year is 2004 and the latest is 2021 and Ginfo's earliest year is 2006 and the latest is 2021.

i know there is a way to write a sas code to pull out these information but don't know how to do it.

 

4 REPLIES 4
Reeza
Super User

Are these SAS data sets or some other file type?

PaigeMiller
Diamond | Level 26

You can read all the file names in a folder into a SAS data set.

https://communities.sas.com/t5/SAS-Programming/How-to-List-all-the-files-in-a-folder/td-p/674065


From there you can pick the ones you want.

--
Paige Miller
Reeza
Super User
If it's SAS data sets, it's slightly easier as you can assign a library and the information is in sashelp.vtable already for you to parse.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1736 views
  • 2 likes
  • 3 in conversation