BookmarkSubscribeRSS Feed
gyambqt
Obsidian | Level 7

Hello everyone:

I am wondering is it possible to write a macro to read file
in different folders.

Like for example, I have 100 folders and within each folder,
it has another folder, within the sub folder It may contain a txt file that I
want to read with SAS. New folder can be created to include new file.

Folder1                                folder2                                file       

A1                                          aa1                                  file1

A2                                          aa2                                (nofile)

…                                            ..                                       …          

A100                                     aa100                             file100

Folder2 is within folder1 and file is stored in folder2.

Thanks

Chen Xu

1 REPLY 1
Reeza
Super User

1. do all files have the exact same structure

2. Is this in Windows or Unix

3. Can you run system commands through SAS on your computer, i.e. X commands or pipe?

You can create a list of the files using OS commands and then use the list of files/paths to import all the files assuming that all files have the exact same structure.

The specific OS command depends on your OS Smiley Happy and if you can run system commands.

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
  • 675 views
  • 0 likes
  • 2 in conversation