BookmarkSubscribeRSS Feed
aj34321
Quartz | Level 8

Dear All,

I'm not sure what wrong i'm doing in below statement but the required output is not generating. Below should generate

C:\CC_MTD_2013-03.xlsx

%let pMTD = '2013-03';

%let pCardMarketingFile = "C:\CC_Mtd_"&%substr(&pMTD,2,7)&".xlsx";

Request experts advice on this..

Thanks a lot.

Rgds, Anil

3 REPLIES 3
damanaulakh88
Obsidian | Level 7

Hi Anil,

Below code is working:-

=====================================================

%let pMTD = '2013-03';

%let pCardMarketingFile = "/shared/BatchServer/CC_Mtd_%substr(&pMTD,2,7).xlsx";

%PUT &pCardMarketingFile;

=====================================================================

Below is the output in the log:-

======================================================================

10         %let pCardMarketingFile = "/shared/BatchServer/CC_Mtd_%substr(&pMTD,2,7).xlsx";

11        

12         %PUT &pCardMarketingFile;

"/shared/BatchServer/CC_Mtd_2013-03.xlsx"

======================================================================

/Daman

aj34321
Quartz | Level 8

Thanks once again....

Jagadishkatam
Amethyst | Level 16

Hi Anil,

Just a small change you need to do like below

the below code will create the macro variable pMTD with value 2013-03.

%let pMTD = '2013-03';

you need to use the pMTD macro variable like below


%let pCardMarketingFile = "C:\CC_Mtd_&pMTD..xlsx";


check the highlighted portion &pMTD. there is another . before the xlsx, &pMTD. will resolve to 2013-03 and the another . separates the filename from the extension. Hope this helps you.


Thanks,

Jagadish

Thanks,
Jag

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 465 views
  • 0 likes
  • 3 in conversation