BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

I want to create Report that have same data as the source data set with the following changes:

1-Values that are repeated in columun "ID"  will be displayed as one value

2-I want to have 2 rows of  columns names :

First row will have the column names

Second row will have the column label name

3-I want that for each customer ID will have a thick ourside border (If possible)

What is the way to do it please?

Ronein_0-1666207319656.png

Data have;			
Input   ID  month  $   Nr_Purchases Total_Amount_Dollars;			
cards;			
1111 2022-01 10 1000
1111 2022-02 18 1400
1111 2022-03 6 300
1111 2022-04 22 2000
1111 2022-05 19 1300
1111 2022-06 14 1500
2222 2022-01 13 800
2222 2022-02 17 1000
2222 2022-03 4 100
2222 2022-04 12 800
2222 2022-05 10 900
2222 2022-06 27 3000
;			
label 			
ID='Customer ID'			
month='YYYY-MM'			
Nr_Purchases='Number of purchase during month'			
Total_Amount_Dollars='Total purchases during month in $'			
;			
Run;			

 

3 REPLIES 3
ballardw
Super User

Is the data already summarized, meaning no calculations needed?

 

Define what you mean by "two rows" of header. Must they physically occupy two different cells of a table or is controlled line wrapping of the output so that it appears that way sufficient?

Do you expect the program to "automagically" parse the label text from variable characteristics? If so, what if the variable has no label? Do you want the variable name repeated?

 

Note: your labels in the data step throw errors. If data is read inline from cards/ datalines then that is the last thing allowed in the step.

Ronein
Meteorite | Level 14

Please look on the photo that I have attached.

You can see that under the column names there is another row with column labels .

IF the variable has no label then display the variable name as the label.

In this report no calculations needed

 

Ksharp
Super User
Data have;   
Input   ID  month  $   Nr_Purchases Total_Amount_Dollars;   
cards;   
1111 2022-01 10 1000
1111 2022-02 18 1400
1111 2022-03 6 300
1111 2022-04 22 2000
1111 2022-05 19 1300
1111 2022-06 14 1500
2222 2022-01 13 800
2222 2022-02 17 1000
2222 2022-03 4 100
2222 2022-04 12 800
2222 2022-05 10 900
2222 2022-06 27 3000
;     
Run;

proc report data=have nowd spanrows;
columns ('ID' ID)  ('month' month)    
('Nr_Purchases' Nr_Purchases) ('Total_Amount_Dollars' Total_Amount_Dollars );
define id/order style={vjust=m just=c};
define month/display;

label    
ID='Customer ID'   
month='YYYY-MM'   
Nr_Purchases='Number of purchase during month'   
Total_Amount_Dollars='Total purchases during month in $'   
; 
run;

Ksharp_0-1666266236598.png

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 473 views
  • 0 likes
  • 3 in conversation