06-26-2017 03:49 PM
I have a very simple program that reads in the contents of all the .csv files in a Windows directory. That part of the program works fine.
I would like to add the file name to each record.
The problem I have is the variable fullfilename contains only 'C:\Users' rather than the full name. I have verified this with PUT statements.
In the log, SAS correctly identifies the full path and name and the proper data is imported but the ticker field (to wihich I tried to assign the parsed filename) is blank, as is the fullfilename field.
Thanks for your help!
Using Windows 10 and SAS 9.4 in Enterprise Guide
infile 'c:\Users\tparrent\Documents\SandP 500 Stock History\daily\table_*.csv'
input dateint unknown open high low close volume;
ticker = scan(scan(fullfilename,-1,'_'),1,'.');
06-26-2017 04:05 PM
When you use the FILENAME you need to actually store it, I don't see that in your code, but it doesn't look complete either....
This is what you'd add and you should have a variable called sourceFile in your dataset. I don't even think fullFileName would be outputted to your dataset otherwise.
sourceFile = fullFileName;
06-26-2017 04:13 PM - edited 06-26-2017 04:14 PM
I tried your sugestions and sourceFileName still contains only 'C:\Users'
I did post the entire code and it does run and import the data from the files
Need further help from the community? Please ask a new question.