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.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.