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 */
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 */
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 */
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 */
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 */
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.