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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.