Hi
i receive every days a file with name: XXXX_YYYYMMDD.
How can i extract the YYYYMMDD to control if all my data have the same date.
I need to compare the date of input data with the date of title file.
Hi NTVM
Please mark this discussion as answered, maybe also provide the approach you did take.
This will help others when searching for this.
thanks
Bruno
Can you please provide some examples. so that we can suggest you ....:)
I have a folder with several files:
Garantees_20120730.txt
Financiero_20120730.txt
I need the date (20120730) to a new variable.
Hi,
Try this..once you get your file name in the data set then you can compare with whatever values you want .hope it helps...
filename dir "F:\TD\test";
data work.dir;
length name $100;
d=dopen("dir");
num=dnum(d);
do i=1 to num;
name=dread(d,i);
r=index(name,".txt");
dt=input(compress(name,,'kd'),yymmdd8.);
output;
end;
format dt date9.;
keep name dt;
run;
Thanks,
Shiva
it´s working...
thanks all.
Hi NTVM
Please mark this discussion as answered, maybe also provide the approach you did take.
This will help others when searching for this.
thanks
Bruno
Here is another approach using 'pipe':
filename fname pipe 'dir c:\test\*.txt /b/s';
data test;
infile fname;
input filename :&$100.;
new_var=substr(filename,prxmatch('/_\d{8}\./', filename)+1,8);
output;
run;
Haikuo
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.