Hello Everyone , I Have This Block of code that i'm trying to run :
Proc Sql;
Create Table Work.Tbl_Dt_Tip_Count As
Select
Prep.Date
, Prep.Name
, Count(distinct Code || name || put(Year, 8.)) As Count
From
(
Select
A.Date
, B.Name
, B.Code
, B.Year
From
Work.Want_Day A
Left join
Ext_Data.Tbl_Date B
on Date >= min(dt_start)
and Date <= Max(Dt_end)
) Prep
Group by
Date
, Name
Quit;
but i ran onto this error :
Summary functions are restricted to the SELECT and HAVING clauses only.
any help would be much appreciated , thank u
Does this run without error?
If so you may have to break this out into two datasets and then do your count.
Proc Sql;
Create Table Work.Tbl_Dt_Tip_Count As
Select
Prep.Date
, Prep.Name
From
(
Select
A.Date
, B.Name
, B.Code
, B.Year
From
Work.Want_Day A
Left join
Ext_Data.Tbl_Date B
on Date >= min(dt_start)
and Date <= Max(Dt_end)
) Prep
Group by
Date
, Name
Quit;
If I understand correctly, I am afraid summary functions are not permitted in an on clause, and so this complicates to further nest like
Proc Sql;
Create Table Work.Tbl_Dt_Tip_Count(drop=min max) As
Select
Prep.Date
, Prep.Name
, Count(distinct Code || name || put(Year, 8.)) As Count
From
(
Select
A.Date
, B.Name
, B.Code
, B.Year
From
Work.Want_Day A
Left join
(select *,min(dt_start) as min, max(Dt_end) as max) B
on min<=Date<=max
) Prep
Group by
Date
, Name;
Quit;
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.