SAS Juletip #9 this year is an introduction on ways to easily read and write multiple sources of data with filename wildcards, dynamic filenames, and keeping track of the source of the data.
Hopefully a few tips or recaps of forgotten features 😉
The examples are very simple, but hopefully, you get the general idea and can adjust them to your own needs.
You should be able to copy, paste, and run the code in your favorite SAS Editor and SAS Version ....
A1) generate two flat files, naming the files based on the data
| SAS PGM | SAS log (partly) |
|
NOTE: The file DYNFILE is:
|
A2) Creating 2 flat files named by content, with no macro
| SAS PGM | SAS Log (partly) |
|
NOTE: The file DYNFILE is: Filename=C:\temp\gender_F.csv,
NOTE: The file DYNFILE is: Filename=C:\temp\gender_M.csv,
NOTE: 9 records were written to the file DYNFILE.
NOTE: 10 records were written to the file DYNFILE.
|
B) Reading files with wildcard and tracking origin
| SAS PGM | SAS log (partly) |
|
NOTE: The infile "c:\temp\gender_*.csv" is:
NOTE: The infile "c:\temp\gender_*.csv" is:
NOTE: 9 records were read from the infile "c:\temp\gender_*.csv".
NOTE: The data set WORK.ALL_GENDERS has 19 observations and 6 variables. |
C) Which SAS Dataset did the data originate from, reading SAS data with wildcard
| SAS PGM | SAS output (partly) | ||||||||||||||||||||||||||||||||||||||||||
|
|
From the SAS Documentation
"Very well done if you got all of those at home." - Richard Osman / Pointless
Great to see a Juletip from you @GertNissen!
I was not aware of (or maybe I had forgetten), the INDSNAME set statement option. Very handy!
@GertNissen Very nice!
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →