☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 08-30-2023 09:57 AM
(1397 views)
Hello, I'm using Proc SQL and have the following statement where I'm deriving a count field. My problem is I am trying to sum up the data and have fields I'm grouping by. Is it possible to SUM the case statement because I don't want each record splitting out on me and I have lots of other fields summing up?
CASE WHEN CODE = 'X' THEN -1 ELSE 1 END as COUNT,
Not working:
SUM (CASE WHEN CODE = 'X' THEN -1 ELSE 1 END as COUNT),
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your close parenthesis is in the wrong spot. Try:
SUM (CASE WHEN CODE = 'X' THEN -1 ELSE 1 END) as COUNT
The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your close parenthesis is in the wrong spot. Try:
SUM (CASE WHEN CODE = 'X' THEN -1 ELSE 1 END) as COUNT
The Boston Area SAS Users Group is hosting free webinars!
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!