I am reading several files into 1 dataset, using a wildcard for the last 8 positions. Now I want to determine these 8 positions, to be also written to my output.
My input files are:
payments_20240110 payments_20240209 payments_20240309 etc ...
So my code is:
data overview;
set payments:;
run;
How do I add a column 'payment_date' to my output? I have been struggling with 'SCAN' function, but I don't get it...
Hello @WimWeyers and welcome to the SAS Support Communities!
The INDSNAME= option of the SET statement stores the dataset name (including the libref, e.g., "WORK") in a temporary variable from which you can extract the date.
Example:
data overview; set payments: indsname=dsn; payment_date=input(scan(dsn,2,'_'),yymmdd8.); format payment_date yymmdd10.; run;
Hello @WimWeyers and welcome to the SAS Support Communities!
The INDSNAME= option of the SET statement stores the dataset name (including the libref, e.g., "WORK") in a temporary variable from which you can extract the date.
Example:
data overview; set payments: indsname=dsn; payment_date=input(scan(dsn,2,'_'),yymmdd8.); format payment_date yymmdd10.; run;
Please show the EXACT code that are using to read this with wildcards.
If this involves reading external files then the INFILE option FILENAME= would create a temporary variable holding the name of the current file being read and could be parsed.
If you are combining data sets by using multiple names of the sets on the SET statement then the INDSNAME= option creates a temporary variable holding the name of the contributing data set that can be parsed.
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.