Hi ,
I am getting duplicate rows in data. The result is correct but it's generating same rows multiple times.
The code is :
proc sql;
create table final as
select month_year , count(distinct ccsid) as unique_visitor
from login_old
where ccsid ne ' '
group by month_year;
quit;
I am getting result as below :
2020-04-01 12989
2020-04-01 12989
2020-04-01 12989
2020-04-01 12989
2020-05-01 17894
2020-05-01 17894
2020-05-01 17894
2020-05-01 17894
I want only one row for each result. Duplication is not needed.
Check the field month_year for leading spaces.
Or invisible characters like TAB ('09'x) CR ('0D'x) LF ('0A'x) non-breaking space ('A0'x) null ('00'x)
Or some of the hyphens are not hyphens but other character like en-dash or em-dash.
You sure you didn't include some third variable in the SELECT list of variables?
If you include non-grouping and non-aggregate values then SAS will remerge the aggregate values back on the results.
SAS will include a note in the log:
1512 proc sql; 1513 select sex, mean(age) as mean_age, height 1514 from sashelp.class 1515 group by sex 1516 ; NOTE: The query requires remerging summary statistics back with the original data.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.