Hi folks, I've got a large dataset of character values for which I want to create a category variable. What I decided would be the easiest approach would be to create arrays for each valid category and then create the variable based on if the value is found in a given array. A simplified example is shown below: data categorize;
set originaldata;
category = "none";
array categoryone (50) $ ("a", "b", "c", "d",...);
array categorytwo (200) $ ("aaa", "aab", "aac",...);
if readvariable in categoryone then category = "1";
else if readvariable in categorytwo then category = "2";
run; What I'm noticing when checking proc freq is that my category variable is "None" for the whole dataset. In trying to figure out why I decided to check my created arrays. Upon checking the arrays I saw that the values were assigned incorrectly such as categoryone1 given a value of "s" instead of the expected value of "a" and that categoryone2-categoryone6 was also given a value of "s". I've tried looking around for what I'm doing wrong in my array assignment and have tried things such as removing the ","s, but to no avail. I realize that my issue is likely multifaceted, but I can't find documentation that states where or how. Help me SAS Community boards. You're my only hope.
... View more