英文:
how to group data by product in this particular dataset
问题
我在SAS Visual Analytics中创建可视化时遇到了问题。
我需要在条形图上可视化数据,其中y轴上是产品名称,x轴上是拥有这些产品的客户数量 - 在每个产品组(名称)中,我需要可视化特定月份内拥有该产品的客户数量,以及去年同一月份 - 以便比较(例如2023年3月和2022年3月)。为了更好地理解,我附上了图表示意图 在这里输入图像描述 - 蓝色柱表示2023年该月份,黑色柱表示2022年该月份的特定产品。
我的数据集如下所示(1表示客户拥有该产品,0表示客户没有):
| 月份 | 客户ID | 产品1 | 产品2 | 产品3 | ... | 产品n |
| ----- | ----------- | 1 | 0 | 1 | | 1 |
| ----- | ----------- | 0 | 1 | 0 | | 1 |
| ----- | ----------- | 1 | 1 | 1 | | 0 |
| ----- | ----------- | 0 | 1 | 1 | | 0 |
问题是,当我从SAS BI导入数据到SAS Visual Analytics时,数据以日期分组的形式可视化,而不是按产品分组。因此,在y轴上不是几个产品,而是两个月份(2022年、2023年)和其中的产品。我很难将数据转换成方便的格式,以便按附图中所示的方式进行可视化。
非常感谢!
我尝试在SAS BI中使用sum()函数对产品求和,并按月份分组,但这并没有解决任何问题,因为我需要按产品分组,但我不知道如何做。在SAS Visual Analytics中,我找不到任何可以按产品而不是日期分组的选项。
英文:
I have trouble creating visualization in SAS Visual Analytics.
I need to visualize data on bar chart where on y axis will be product names and on x axis number of customers who have these products - in each product group (name) I need to visualize number of customers who have this product in the particular month and the same month year ago - for comparison (f.e. march 2023 and march 2022). For better understanding I am attaching sketch of graph enter image description here - blue column month 2023, black column month 2022 of the particular product.
My dataset looks like this (1 represents that customer has the product and 0 that he has not):
| month | customer_id | product1 | product2 | product3| ... | productn |
| ----- | ----------- | 1 | 0 | 1 | | 1 |
| ----- | ----------- | 0 | 1 | 0 | | 1 |
| ----- | ----------- | 1 | 1 | 1 | | 0 |
| ----- | ----------- | 0 | 1 | 1 | | 0 |
The problem is when I am importing data into SAS Visual Analytics from SAS BI, it is visualized in the form of groups by date, not product. So instead of several products on y axis there are 2 month (2022,2023) and products within it. And I struggle transforming the data into convenient format when I would be able to visualize it as it is presented on the attached image.
Thank you in advance!
I tried to sum() products in SAS BI and group it by month, by that did not solve anything bc I need to group it by product, but I do not know how. In SAS Visual Analytics I could not find any options that could group it by product instead of date.
答案1
得分: 1
更好的数据结构如下:
月份 | 客户ID | 产品编号 | |
---|---|---|---|
一月 | 1 | 1 | |
一月 | 1 | 3 | |
一月 | 1 | n |
这将使您能够按产品编号(或产品名称或任何最合适的方式)进行分组。
英文:
A better data structure for this would be
month | customer_id | product_num | |
---|---|---|---|
Jan | 1 | 1 | |
Jan | 1 | 3 | |
Jan | 1 | n |
This would allow you to group by product number (or product name or whatever makes the most sense).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论