Adding leading underscores to variables

Reply
Contributor
Posts: 30

Adding leading underscores to variables

This is for macro automation purposes,  I want to use my first variable x, to create a macro for the 2nd variable var2 which I already have code for

data _null;

set boundvec;

call symputx(x,var2,'G');

run;

but of course I get an error because x is a number; how can I simply add underscores infront of my x variables?

obs  x     var2

11521.25175485
22855.9807884
331422.6889005
441929.7196005
552456.6264165
663641.1847645
774406.201729
Super Contributor
Posts: 333

Re: Adding leading underscores to variables

Asked and answered:

Is this what you are looking for?:

call symputx( cats("_",x),var2,'G');

Hope this helps!

EJ

Ask a Question
Discussion stats
  • 1 reply
  • 459 views
  • 0 likes
  • 2 in conversation