incorrect SQL generated to summarize data
@2TomLi is already working on this.
Since Apr 8, 2024.
Assessment
This issue has not been assessed yet.
Description
/* summarize sashelp.class with one row per age and a variable called "namelist" containing a comma delimited list of names */
Select Generate Code.
The generated DATA step works if sashelp.class is sorted by AGE:
data summarized_class;
set sashelp.class;
by age;
length namelist $200;
retain namelist;
if first.age then namelist = name;
else namelist = catx(',', namelist, name);
if last.age then output;
drop name;
run;
The generated SQL with does not create the same or desired output. The name do not get concatenated per age.
proc sql;
create table summary as
select age,
catx(", ", name) as namelist
from sashelp.class
group by age;
quit;
Also generates this log message:
WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither the SELECT clause nor the optional HAVING
clause of the associated table-expression referenced a summary function.
Other incorrect SQL variations generated when I tweaked the comment language:
proc sql;
create table new_dataset as
select age,
catx(',', name_list) as namelist
from (select age,
catx(',', name) as name_list,
count(*) as count
from sashelp.class
group by age, name
having count > 0);
quit;
proc sql;
create table new_dataset as
select age,
catx(',', listagg(name, ',')) as namlist /* do not think listagg() is a SAS function *?
from sashelp.class
group by age;
quit;
- Dominant language
- TypeScript
- Stars
- 12
- Forks
- 1
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sassoftware/sas-copilot
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
sassoftware/sas-copilot#75 ·
-
bug
sassoftware/sas-copilot#74 · 1 assignee ·
-
enhancement
sassoftware/sas-copilot#72 · 1 comment · 1 assignee ·
-
bug
sassoftware/sas-copilot#71 · 1 assignee ·
-
bug
sassoftware/sas-copilot#68 · 1 assignee ·
All issues in sassoftware/sas-copilot
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·