BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
WimWeyers
Calcite | Level 5

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...

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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;

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

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;
ballardw
Super User

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.

WimWeyers
Calcite | Level 5
INDSNAME = works perfectly! Thank you both.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1082 views
  • 2 likes
  • 3 in conversation