Supose i have a macro variable that is a list of words
%LET myvariable= Avocado Banana Rice Corn Mango Milk Strawberry Banana Banana Lime;
Now, i wish to have a dataset where each row is one word of that list, plus a ID number
ID Ingredient
1 Avocado
2 Banana
3 Rice
4 Corn
5 Mango
6 Milk
7 Strawberry
8 Banana
9 Banana
10 Lime
I tried something like this:
DATA food;
DO id = 1 TO 10;
Ingredient= SCAN(&myvariable.,id,' ');
OUTPUT;
END;
RUN;
But this generated an error: “ERROR 388-185: Expecting an arithmetic operator.”
This seems like a trivial thing to do, but somehow i’m stuck. So any help would be greatly appreciated.
Some background:
In my real dataset, this macro variable is created via an PROC SQL, from a dataset where each entry have several words, separated by an space. Something like this:
Product_ID Ingredients
1 Sugar Milk Vanilla
2 Corn Sugar Banana
3 Apple Banana Maple_Syrup Oats
... ...
Very close. Without commenting on why you want to do this, you just need to put double-quotes around your macro variable name: