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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.