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.
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 save with the early bird rate—just $795!
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.