Is it possible to create an array with string values (not variables) to rename values?
I know a macro does this, but it's already inside a parent macro.
I know that this query does not work, but it would be something like this:
DATA ONE;
SET TWO;
ARRAY REWRITE{2, 5} "LilyOrchid" "LilyRose" "LilyRoseOrchid" "LilyRoseJasmine" "LilyRoseOrchidJasmine" "2FOrchid" "2FRose" "3FOrchid" "3FJasmine" "4F";
DO i= 1 to 5;
IF FLOWER_ARRANGEMENT=REWRITE{1, i} THEN FLOWER_ARRANGEMENT=REWRITE{2, i};
END;
RUN;
Arrays are addressing mechanisms for variables, you can't have "variable-less" arrays. But you can define "temporary arrays". Google "sas temporary arrays" for further information.
Try adding this word:
_temporary_
inside the array statement, just after the closing brackets.
ARRAY REWRITE{2, 5} _temporary_ "LilyOrchid" ............................;
Thank you. It was good to discover that this is possible.
Formatting might work for you.
proc format;
value $Gender
'M'='Male'
'F'='Female'
other='UNK';
run;
data test;
set sashelp.class;
format sex $Gender.;
run;
Thank you. I'll choose the array because I'd rather not interrupt the dataset in what I'm doing
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.