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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.