BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

I need to help in my code in data step two below. In my actual program i had to create a macro variable using proc sql and use it in a data step similar to below. 

In data step two below, i need to create variable 'C' with value='TREATEMENT A Respond'. But i am getting errors. Please help. Thank you

%let treat1=TREATMENT A;
%put &treat1.;
data one;
input a b $;
datalines;
1 a
2 b
;

data two;
set one;
if b='a' then do;
c=&treat1.|| 'respond';
end;run;
3 REPLIES 3
novinosrin
Tourmaline | Level 20
%let treat1=TREATMENT A;
%put &treat1.;
data one;
input a b $;
datalines;
1 a
2 b
;

data two;
set one;
if b='a' then do;
c="&treat1."|| 'respond';
end;run;

 Correction was c="&treat1."|| 'respond';

r_behata
Barite | Level 11
data two;
set one;
if b='a' then do;
c=catx(' ',"&treat1.","respond");
end;
run;

You may also use the CATX function.

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
  • 3 replies
  • 29687 views
  • 3 likes
  • 4 in conversation