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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.