Hey everyone,
I am trying to create a variable that references the input file's filename (without extension). Is there a way to do this? I am going to combine multiple test files into one excel file so I can run pivot tables for grade reports. Using the filename would be an easy way to assign the module or test name.
for example:
data work.test;
infile 'C:\xxx.csv' dlm=',';
Module='INSERT CODE FOR FILENAME REFERENCE HERE'
length Student $20;
Input Student Grade;
format grade percent6.;
run;
proc print data=work.test;
run;
Then under the variable "Module", you would see "test 1" "test 2" "test 3" etc.
Thanks for your help!
Add this to your infile statement ....
specifies a variable that SAS sets to the physical name of the currently opened input file. Like automatic variables, the FILENAME= variable is not written to the data set.
See:FILEVAR=
Example:Reading from Multiple Input Files
then module=whatever
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.