DATA Step, Macro, Functions and more

Resolving 2 consecutive macro variables with a space

Reply
Contributor
Posts: 24

Resolving 2 consecutive macro variables with a space

Dear all,

here is an example:

%let client = ABC PHARM;

%let study = 123;

 

title1 "&client &study" ;

proc print;

run;

 

how do I get a space between client and study in the title? thanks so much!

Valued Guide
Posts: 797

Re: Resolving 2 consecutive macro variables with a space

I ran this version of your program and got the result you want:

 

%let client = ABC PHARM;
%let study = 123;

title1 "&client &study" ;
proc print data=sashelp.class (obs=1);
run;

 

producing ...

                                                     ABC PHARM 123                         09:41 Thursday, June 29, 2017   3

                                        Obs     Name     Sex    Age    Height    Weight

                                          1    Alfred     M      14      69       112.5

 

 

Do you not get the same results?

Contributor
Posts: 24

Re: Resolving 2 consecutive macro variables with a space

Hi thanks --


I am not getting a space between 'Pharm' and '123'

Thanks Smiley Happy
Super User
Posts: 10,516

Re: Resolving 2 consecutive macro variables with a space


jill1 wrote:
Hi thanks --


I am not getting a space between 'Pharm' and '123'

Thanks Smiley Happy

I agree with @mkeintz, I get a space in the title.

 

You may have to show the log including and ODS destination and options. If so please post the log in a code box opened using the forum {i} menu icon to prevent the message window from reformatting text.

PROC Star
Posts: 1,233

Re: Resolving 2 consecutive macro variables with a space

I can't imagine how it could be that you don't get a space.

 

Just for curiosity, and to remove ODS from the process,  what to you get from:

 

%let client = ABC PHARM;
%let study = 123;
title1 "&client &study" ;

proc sql;
  create table mytitle as 
  select text 
  from dictionary.titles;
quit;


data _null_;
  set mytitle;
  if text="ABC PHARM 123" then do;
    put "Confirmed: title has a space! " text=;
  end;
  else do;
    put "ERROR: No space! " text=;
  end;
run;

?

 

 

In the log, I get:

Confirmed: title has a space! text=ABC PHARM 123
Ask a Question
Discussion stats
  • 4 replies
  • 121 views
  • 1 like
  • 4 in conversation