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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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