BookmarkSubscribeRSS Feed
FaridNasrAlDeen
Fluorite | Level 6
Hello everyone. I wonder how can I ungroup objects in a dataset using an sql code?
I have a dataset containing several companies. I used "casewhen" to group companies in one batch. For companies that I needed to have data on individually I indicated their tax id numbers.
My question is: How can I form a table of data without indicating individual group numbers there?
4 REPLIES 4
andreas_lds
Jade | Level 19

I don't have any idea what "ungroup" could mean.

Please post the data you have in usable form and the expected result.

FaridNasrAlDeen
Fluorite | Level 6
Unfortunately, I cannot post data.

However I can describe the task from a different perspective.

Let us say I have 5 companies with various commercial indicators related to
them.

I created a variable "Major Companies" by introducing a code:

%let Major_Companies = ('023478', '785466', '667743');

*Now I use proc sql to create a table:*

proc sql;

create table month_report as
select
date,
type,
payment_form,
product_type,
CASE
WHEN CLIENT IN &Major_Companies THEN CLIENT
WHEN cash_disb = 'Y' THEN 'Cash_payments'
ELSE 'OTHERS'
end as 'client1'

The code is slightly larger, but what I want is to include all customers in
the table without grouping them into "Others" pack. Can that be done by
deleting that string of code or should I specify ALL in the parenthesis
when I introduce the Major_Companies variable?
Reeza
Super User
Make some fake data in Excel that mimics your actual data.

Seems like you could just group on the CLIENT field instead of CLIENT1 field instead to get what you want?
Depends what you want to do with that second condition:
WHEN cash_disb = 'Y' THEN 'Cash_payments'
Sajid01
Meteorite | Level 14

Hello @FaridNasrAlDeen 
From the code you have shown , you are using case statement to create a new variable client1.
The rest of the data is intact.
Just ignore this variable.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 751 views
  • 0 likes
  • 4 in conversation