DATA Step, Macro, Functions and more

Concatenation of a variable and a litteral string in a put statement

Accepted Solution Solved
Reply
Regular Contributor
Posts: 194
Accepted Solution

Concatenation of a variable and a litteral string in a put statement

Hi all,

I would like to know if there is a way to remove the space introduced

by the put statement in the following data step.

data _NULL_;

hel="hel";

put Hel "lo";

run;

Output :

Hel lo

     ^

Of course, I could generate the string in a previous statement, but

this is what I want to avoid since I have a lot of such put statements.

Thanks


Accepted Solutions
Solution
‎08-28-2014 07:00 AM
PROC Star
Posts: 1,234

Re: Concatenation of a variable and a litteral string in a put statement

One way:

8    data _NULL_;
9      hel="hel";
10     put hel +(-1) "lo";
11   run;

hello

View solution in original post


All Replies
Super User
Super User
Posts: 7,413

Re: Concatenation of a variable and a litteral string in a put statement

Pop the format in:

data temp;

hel="hel";

put hel $3. "lo";

run;

Solution
‎08-28-2014 07:00 AM
PROC Star
Posts: 1,234

Re: Concatenation of a variable and a litteral string in a put statement

One way:

8    data _NULL_;
9      hel="hel";
10     put hel +(-1) "lo";
11   run;

hello

Regular Contributor
Posts: 194

Re: Concatenation of a variable and a litteral string in a put statement

Thanks a lot !

I thought of using the format but the string lengths can vary between observations. "+(-1)" is just what I needed.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 187 views
  • 3 likes
  • 3 in conversation