Hi,
I have a dataset that looks like this
A B
fast 1
fast 1
slow 2
slow 2
other 3
other 3
fast 4
How can I use a macro step to print an error, where values are not one to one in column a and column b? For example in the above dataset "slow"-2, "other"-3 are one to one, but "fast" -1 is not one to one.
For my output dataset I want:
error
fast -1 is not one to one
Macro not needed.
proc sql;
create table want as select distinct a,b from have order by a,b;
quit;
data _null_;
set want;
by a;
if first.a and not last.a then
put a= b= "is not one to one";
run;
Macro not needed.
proc sql;
create table want as select distinct a,b from have order by a,b;
quit;
data _null_;
set want;
by a;
if first.a and not last.a then
put a= b= "is not one to one";
run;
Thanks for the quick response! However this method still requires some eyeballing work. Is there a way to directly print out only the lines with error?
@laiguanyu001 wrote:
Thanks for the quick response! However this method still requires some eyeballing work. Is there a way to directly print out only the lines with error?
I just updated the code to handle this.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.