BookmarkSubscribeRSS Feed
SASuser8564
Calcite | Level 5

I created a sample dataset to show what I have and what I want but I don't know how to get there. I am converting SQL code to SAS. 

The input: 

RowMember_OrderIDMember_NameCHECK_DATECLAIM_IDREVENUE_CODEDIAGNOSIS_CODESSERVICE_FROM_DTSERVICE_THROUGH_DTPAYORRateSUM_OF_DAYSSum_Of_Claim_AmtSUM_OF_PAID_AMT
1112345smith,john2/2/2022678910123a1################County1838.7097316000026000
2112345smith,john3/2/2022111213123a11/1/2022########county1838.7097316000026000
3112345smith,john3/30/2022141516123a12/1/2022########county11208.333246500029000
4223456doe,jane9/21/20221546123b28/2/20228/8/2022county2230071680016100
5223456doe,jane9/21/202215465123b28/9/2022########county2230071680016100
6223456doe,jane9/28/20228788123b2################county21788.88991680016100
7223456doe,jane10/12/2022212121212123b2########9/4/2022county22300716800

16100

 

And the output I want: 

IDMember_nameCHECK_DATECLAIM_IDREVENUE_CODEDIAGNOSIS_CODESSERVICE_FROM_DTSERVICE_THROUGH_DTSUM_OF_DAYSSUM_OF_CLAIM_AMTSUM_OF_PAID_AMTPAYORRate
12345smith,john2/2/2022678910123A1################316000026000County1838.7097
12345smith,john3/2/2022111213123A11/1/2022########316000026000County1838.7097
12345smith,john3/30/2022141516123A12/1/2022########246500029000County11208.333
     Total  38118500081000  
23456doe,jane9/21/20221546123B28/2/20228/8/202271680016100County22300
23456doe,jane9/21/202215465123B28/9/2022########71680016100County22300
23456doe,jane9/28/20228788123B2################91680016100County21788.889
23456doe,jane10/12/2022212121212123B2########9/4/202271680016100County22300
     Total  1056720064400  

 

I know I can create this with the totals in Proc Report but I need it as a table to export to Excel. Any ideas on how I can create these subtotals by ID in a dataset? 

 

(All data is made up for the sake of the sample.)

 

 

 

 

2 REPLIES 2
JOL
SAS Employee JOL
SAS Employee

You can use Proc Print and ODS statements to export to Excel.  See sample code below using SASHELP.CARS 

 

proc sort data = sashelp.cars out=cars;
by make;
run;

ods excel file = "c:\temp\cars.xlsx" options(sheet_interval='none');

proc print data=cars;
id make;
by make;
sum msrp invoice;
run;

ods excel close;

 

Cynthia_sas
SAS Super FREQ
Hi: If you can get the look of the table you want, you could either send the PROC REPORT output directly to ODS EXCEL OR, you can use the OUT= option with PROC REPORT to create an OUTPUT dataset and then you could send that dataset to Excel.
Cynthia

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 399 views
  • 2 likes
  • 3 in conversation