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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 785 views
  • 2 likes
  • 3 in conversation