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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.