Hi!
If you have a statement such as S=C, then you will not get the desired results (I don't think so, anyway.) Maybe this alternate program will help explain it. Consider this scenario. I have some data with home emails, work emails and and a variable that contains the person's actual email that they said they wanted to be the one used.
I want a new variable (SendTo) created in the data that contains either WORK or HOME e-mail as the value of the SendTo column.
So, first, let's say that the data looks like this. And the variables are Name, Home, Work, and Use
[pre]
"Anne", "anne@aa.com", "anne@qq.com", "Home"
"Bob", "Bob@bb.com", "Bob@rr.com", "Work"
"Chet", "Chet@cc.com", "Chet@tt.com", "Work"
"Diane", "Diane@dd.com", "Diane@tt.com", "Home"
"Eudora", "Eudora@ee.com", "Eudora@rr.com", "Home"
"Fiona", "Fiona@ff.com", "Fiona@xx.com", "Other"
[/pre]
and that the data lives in a file called email_info.txt in my c:\temp directory. Next, I need to read the data and make the SendTo column:
[pre]
DATA T;
LENGTH SendTo Home Work $20 Use $5;
infile 'c:\temp\email_info.txt' dsd;
input name $ Home $ Work $ Use $ ;
SendTo=vvaluex(Use);
run;
[/pre]
So the key statement is where the SendTo variable will take on the value of whereever the Use variable points to (either Work or Home).
Then if you do a proc print on the final data set (after running the above program), you will see:
[pre]
Obs name Home Work Use SendTo
1 Anne anne@aa.com anne@qq.com Home anne@aa.com
2 Bob Bob@bb.com Bob@rr.com Work Bob@rr.com
3 Chet Chet@cc.com Chet@tt.com Work Chet@tt.com
4 Diane Diane@dd.com Diane@tt.com Home Diane@dd.com
5 Eudora Eudora@ee.com Eudora@rr.com Home Eudora@ee.com
6 Fiona Fiona@ff.com Fiona@xx.com Other
[/pre]
In this example, vvaluex acted as a lookup within one row. For Anne's row, the value of Use was Home.
So when SAS was on Anne's row of data, imagine that this is what happened:[pre]
SendTo=vvaluex(Use) --> SendTo=vvaluex(Home) --> SendTo=anne@aa.com[/pre]
On the other hand, for Chet's row, the resolution for the function would be:[pre]
SendTo=vvaluex(Use) --> SendTo=vvaluex(Work) --> SendTo=Chet@tt.com[/pre]
It's hard to figure out exactly what the original person needed to do...since the data was made up data. But, if I had used SendTo = Use as the assignment statement in my code, then I would NOT have gotten the actual email address for the value of SendTo, I would just have gotten either Home or Work (or whatever the value of Use was).
There are a lot of ways to do lookups with SAS, including, but not limited to, Proc Format, IF statements, Merge, Join -- most of these involve a fixed list. On the other hand, the VVALUEX function allows you to do a lookup on the same row. Tech Support may be your best bet for solving these kinds of problems because each method has pros and cons that can change depending on the kind of data you have, the kind of lookup you need to do and the size of the tables involved or the the kind of variables involved.
Good luck!
cynthia