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

data blah;

   set blahblah;

   length formula $ 50;

   formula = "=CONCATENATE($B" || trim(_N_) || ",$G" || trim(_N_) || ")";

run;

 

 

results in 

=CONCATENATE($B         1,$G          1)

 

how do i get rid of those spaces? 🙂 thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20
data _null_;
   string="=CONCATENATE($B" || trim(_N_) || ",$G" || trim(_N_) || ")";
   newstring=compress(string);
   put string;
   put newstring;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20
data _null_;
   string="=CONCATENATE($B" || trim(_N_) || ",$G" || trim(_N_) || ")";
   newstring=compress(string);
   put string;
   put newstring;
run;
StaticFX
Obsidian | Level 7

compress!! thats what i was thinking... but why not just do this?

 

string="=CONCATENATE($B" || compress(_N_) || ",$G" || compress(_N_) || ")";

it works...

Reeza
Super User

Just a note that if you're making Excel cell references, it tends to use RC notation for interaction with some things such as DDE. Not sure what ODS EXCEL or TAGSETS use.

Tom
Super User Tom
Super User

Use one the series of concatenate functions that SAS has. 

1569  data _null_;
1570   do _n_=1 to 3 ;
1571     length formula $ 50;
1572     formula = cats('=CONCATENATE($B',_N_,',$G',_N_,')');
1573     put _n_= formula = :$quote.;
1574   end;
1575  run;

_N_=1 formula="=CONCATENATE($B1,$G1)"
_N_=2 formula="=CONCATENATE($B2,$G2)"
_N_=3 formula="=CONCATENATE($B3,$G3)"

They will also silently convert numbers to strings for you unlike when you apply a character function like trim() to them.  But if your numbers are not integers or can get too big then you should use PUT() function to convert your numbers to string rather than letting SAS guess at what you want.

 

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
  • 4 replies
  • 1331 views
  • 2 likes
  • 4 in conversation