Start with this:
data want;
set have;
v2 = compress(var2, "-");
if anydigit(v2) and not anyalpha(trimn(v2)) then do;
if missing(var3) then do;
call missing(var2);
output;
var1 = v2;
output;
end;
else do;
call missing(var2);
v3 = var3;
call missing(var3);
output;
var3 = v3;
output;
var1 = v2;
call missing(var3);
output;
var3 = v3;
output;
end;
end;
else output;
drop v2 v3;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.