BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
acordes
Rhodochrosite | Level 12

The code does what I want him to do, but it seems so overcomplicated what I do...

 

The final macro variable resolves to 

 

O:\Arne\OUTINSIGHTS\heat_ALL_retail_2017_2018_AB_CD.htm

 

That's correct, but there has to be an easier way to achieve this.

 

Bye, Arne

 

OPTIONS MLOGIC SYMBOLGEN;

%LET BRA = "ALL";
%LET PRO1= "AB";
%LET PRO2="CD";
%LET YE1=2017;
%LET YE2=2018;


%LET H1=%SYSFUNC(CATX("_",&PRO1, &PRO2)); 
%let H2=%sysfunc(translate(%superq(H1),%str( ),%str(%")));
%PUT &H2;

%LET NA=  %SYSFUNC(CATX("",O:\Arne\OUTINSIGHTS\heat_,%SYSFUNC(DEQUOTE(&BRA.)),_retail_,&YE1,_,&YE2,_, &H2.,.htm)); 
%let NA1=%sysfunc(translate(%superq(NA),%str( ),%str(%")));
%LET NA2=%sysfunc(COMPRESS(&NA1));





FILENAME HT_APP "&NA2";
ODS GRAPHICS ON/ IMAGEMAP=ON IMAGENAME=&BRA. width=7in height=5in;
ODS HTML FILE=HT_APP NOGTITLE GPATH='O:\Arne\OUTINSIGHTS\' (url='');

title "%SYSFUNC(DEQUOTE(&BRA.)) Retail &YE1. &YE2. %SYSFUNC(DEQUOTE(&PRO1.)) %SYSFUNC(DEQUOTE(&PRO2.)) :  ";

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@acordes wrote:

The code does what I want him to do, but it seems so overcomplicated what I do...

 

The final macro variable resolves to 

 

O:\Arne\OUTINSIGHTS\heat_ALL_retail_2017_2018_AB_CD.htm

 

That's correct, but there has to be an easier way to achieve this.

 

 

%LET BRA = "ALL";
%LET PRO1= "AB";
%LET PRO2="CD";


 

Macro variable values are almost never surrounded by quotes. Then you don't need to de-quote them later.

 

So, after you remove those annoying quotes, to get &NA2

 

%let na2 = O:\Arne\OUTINSIGHTS\Heat_&bra._retail_&ye1._&ye2._&pro1._&pro2..htm;

 

 

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

@acordes wrote:

The code does what I want him to do, but it seems so overcomplicated what I do...

 

The final macro variable resolves to 

 

O:\Arne\OUTINSIGHTS\heat_ALL_retail_2017_2018_AB_CD.htm

 

That's correct, but there has to be an easier way to achieve this.

 

 

%LET BRA = "ALL";
%LET PRO1= "AB";
%LET PRO2="CD";


 

Macro variable values are almost never surrounded by quotes. Then you don't need to de-quote them later.

 

So, after you remove those annoying quotes, to get &NA2

 

%let na2 = O:\Arne\OUTINSIGHTS\Heat_&bra._retail_&ye1._&ye2._&pro1._&pro2..htm;

 

 

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 542 views
  • 3 likes
  • 2 in conversation