Data T;
length s $1;
merge
vendor (in = a)
clue (in = b keep = clue mail_name)
;
LENGTH PROD_TP $4;
by mail_name;
if (a);
if index(upcase(clue),'{LOLO}') > 0 then
do;
if lolo = "Q" then
cot=tranwrd(upcase(clue),'{LOLO}','T');
else if lolo = "P" then
cot=tranwrd(upcase(clue),'{LOLO}','U');
end;
else cot = clue;
if %str(Language = 'N');
If (Unit = 'CC' and Deliver in('AC' 'BC')) then
FINAL = compress(Name1||',!,'||cot);
else FINAL = compress(Name||',!,'||cot);
if s = 'Y' then
delete;
run; Hello, I have 2 datasets that I'm trying to merge and get a certain desired output by running a macro in a remote location. Since that macro is being utilized for other codes, I cannot make any changes to it. I tried copy pasting that macro in a seperate SAS program to understand what it is doing, but I can't see which if conditions are being followed. (already tried adding options mlogic, symbolgen and mprint). The only place where I can make a change is in the code that creates the Vendor dataset. I've added the sample datasets, the macro code and the log. Assuming both the datasets are sorted by the 'by' variable, the merge does not seem to be working correctly. Appreciate the help in helping me understand the problem. ‘Vendor’ dataset: Name Language Mail_Name Unit User1 N Mail MailUnit User2 N Mail MailUnit User3 N Mail MailUnit Clue dataset: Name_Vendor Clue Mail_Name Vendor Test Mail Vendor1 Test1 Mail Macro code: Data T; length s $1; merge vendor (in = a) clue (in = b keep = clue mail_name) ; LENGTH PROD_TP $4; by mail_name; if (a); if index(upcase(clue),'{LOLO}') > 0 then do; if lolo = "Q" then cot=tranwrd(upcase(clue),'{LOLO}','T'); else if lolo = "P" then cot=tranwrd(upcase(clue),'{LOLO}','U'); end; else cot = clue; if %str(Language = 'N'); If (Unit = 'CC' and Deliver in('AC' 'BC')) then FINAL = compress(Name1||',!,'||cot); else FINAL = compress(Name||',!,'||cot); if s = 'Y' then delete; run; Current O/P: S Name Language Mail_Name Unit Clue PROD_TP LOLO COT Unit Deliver FINAL Name1 User1 N Mail MailUnit User1,!, . User2 N Mail MailUnit User2,!, . User3 N Mail MailUnit User3,!, . The O/P that I'm trying to get (values in Clue, COT and FINAL): S Name Language Mail_Name Unit Clue PROD_TP LOLO COT Unit Deliver FINAL Name1 User1 N Mail MailUnit Test Test User1,!, Test . User2 N Mail MailUnit Test Test User2,!, Test . User3 N Mail MailUnit Test Test User3,!, Test . Log: NOTE: Variable s is uninitialized. NOTE: Variable PROD_TP is uninitialized. NOTE: Variable lolo is uninitialized. NOTE: Variable Unit is uninitialized. NOTE: Variable Deliver is uninitialized. NOTE: Variable Name1 is uninitialized. WARNING: Multiple lengths were specified for the BY variable mail_name by input data sets. This might cause unexpected results.
... View more