I'm looking for a way to get the contents/variables of array.
For example
data work.chars;
char1 = "aa";
char2 = "bb";
output;
run;
data work.test2;
length _GETNAMES $40. ;
set work.chars;
array ch _CHARACTER_;
do over ch;
_GETNAMES = vname(ch);
if _GETNAMES ^= "_GETNAMES" then put _GETNAMES;
end;
run;
We know that array "ch" has variable cha1 char2 inside,
Is there a way to get it with 1 time?
The result is "cha1 char2" or "cha1,char2".
So as to allow “vlabel” function to get the content of label in the variable.
I'm searching a function or way to catch contents of array.
Sincerely.
You can build the list this way:
data work.chars;
char1 = "aa";
char2 = "bb";
output;
run;
data work.test2;
if 0 then set work.chars;
array ch _CHARACTER_; /* Declared before creating variable _GETNAMES */
length _GETNAMES $40 ;
do i = 1 to dim(ch);
_GETNAMES = catx(", ", _GETNAMES, vname(ch{i}));
end;
put _GETNAMES;
output;
stop;
run;
You can build the list this way:
data work.chars;
char1 = "aa";
char2 = "bb";
output;
run;
data work.test2;
if 0 then set work.chars;
array ch _CHARACTER_; /* Declared before creating variable _GETNAMES */
length _GETNAMES $40 ;
do i = 1 to dim(ch);
_GETNAMES = catx(", ", _GETNAMES, vname(ch{i}));
end;
put _GETNAMES;
output;
stop;
run;
Hi,PGStats
It works well.
Thank you so much!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.