Hi, I am using SAS 9.3.
I would like to keep duplicate rows only and just print them out, but not saving to another dataset.
Now, I get the code which is creating a new dataset to save duplicate rows below.
proc sql;
create table dup as
select *
from have
group by Birth, Sex, Height, Weight
having count(*) > 1;
quit;
But actually, I just want to print it out. Does anyone have the suggestions?
Perhaps, if duplicate rows then print it out. Maybe.
Thanks, and appreciate!
JC
I'm 99% certain on this ...
It's creating a table because you asked SQL to create a table. To create a report instead, just remove one line from the program:
create table dup as
I'm 99% certain on this ...
It's creating a table because you asked SQL to create a table. To create a report instead, just remove one line from the program:
create table dup as
Are you saying there might be no duplicates, but SQL still prints a report? To handle that, you might as well keep your original program, and then add:
proc print data=dup;
run;
When there are no observations to print, PROC PRINT sends a message to the log but sends nothing to the output. If you take that approach, you might switch to creating a view instead of a table:
create view dup as ..........
But if the number of duplicates is going to be small, that wouldn't be necessary.
No, CALL SYMPUT can only be part of a DATA step.
SQL does have ways to create macro variables, using INTO : but it can't use CALL SYMPUT.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.