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

I would like to obtain the actual element name in a data step array as opposed to the value of that column. Is there any way to obtain the value? Example below;

data _null_;

     array test {1} helloworld;

    

     do j=1 to 1;

          call symput('name', test{1} );

     end;

run;

%put &name; /*I would like the name value to be helloworld */

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

VNAME function

data _null_;

     array test {1} helloworld;

   

     do j=1 to 1;

          call symput('name', vname(test{1}) );

     end;

run;

%put &name; /*I would like the name value to be helloworld */

View solution in original post

3 REPLIES 3
Reeza
Super User

VNAME function

data _null_;

     array test {1} helloworld;

   

     do j=1 to 1;

          call symput('name', vname(test{1}) );

     end;

run;

%put &name; /*I would like the name value to be helloworld */

art297
Opal | Level 21

data _null_;

     array test{1} $20. ("helloworld");

   

     do j=1 to 1;

          call symput('name', test{1} );

     end;

run;

%put &name; /*I would like the name value to be helloworld */

bream_bn
Fluorite | Level 6

Wow you guys are quick!!!
Reeza works exactly as expected even with multiple array values.
Arthur yours works as well it just was not as straight forward how to add multiple array values;

data _null_;

     array test {2} hello world;

  

     do j=1 to 2;

          call symput('name', vname(test{j}) );

     end;

run;

%put &name; /*Puts world */

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 1405 views
  • 3 likes
  • 3 in conversation