I have two string variables that contain movie names: Name1 and Name2. Some values repeat, both within each one and across the two.
Example:
Names1
Indiana Jones
James Bond
Names2
James Bond
Top Gun
I need to loop through all of the movie names, but only once per name.
The general steps I have in mind:
1. Create a macro that contains a unique list of names from both variables.
2. Loop through the macro and tabulate each movie name with a third variable.
I am having a lot of trouble, I think mostly because of the spaces in the movie names. I know about `" "', used for quotation marks within strings, but I can't get the macro to work.
I used levelsof and stored the results in a local macro. I then looped through the local variable and concatenated all of the values into a new veritable.
The variable first looked like this: Indiana Jones James Bond Top Gun.
Then I added quotation marks: "Indiana Jones" "James Bond" "Top Gun."
And created a macro to hold all of these.
But I have tried everything and could not loop through that macro. I tried without quotation marks, with quotation marks, and `" "' . Nothing has worked.
There must be a better way in the first place.
Any suggestions?
Thank you.
Example:
Names1
Indiana Jones
James Bond
Names2
James Bond
Top Gun
I need to loop through all of the movie names, but only once per name.
The general steps I have in mind:
1. Create a macro that contains a unique list of names from both variables.
2. Loop through the macro and tabulate each movie name with a third variable.
I am having a lot of trouble, I think mostly because of the spaces in the movie names. I know about `" "', used for quotation marks within strings, but I can't get the macro to work.
I used levelsof and stored the results in a local macro. I then looped through the local variable and concatenated all of the values into a new veritable.
The variable first looked like this: Indiana Jones James Bond Top Gun.
Then I added quotation marks: "Indiana Jones" "James Bond" "Top Gun."
And created a macro to hold all of these.
But I have tried everything and could not loop through that macro. I tried without quotation marks, with quotation marks, and `" "' . Nothing has worked.
There must be a better way in the first place.
Any suggestions?
Thank you.
Comment