Help using Base SAS procedures

sum by based on Dates

Reply
Regular Contributor
Posts: 229

sum by based on Dates

i have

data report;
input dat tran;
format dat mmddyy8.;
cards;
10/12/98 45
10/16/98 66
10/26/98 23
11/06/00 89
11/20/00 75
11/23/00 45
11/29/00 63

Now i want the sum of tran between 10/12/98 to 10/16/98, and i want the sum of tran from 11/06/00 to 11/23/00 in to a new variable Total .if the trans is not between the mentioned dates it should remain same . Message was edited by: Main
Super Contributor
Super Contributor
Posts: 3,174

Re: sum by based on Dates

A set of SAS assignment statements as illustrated below will work:

IF THEN ;
ELSE IF THEN ;
ELSE ;

Explore using SAS literal strings expressed as DATE values for your defined as explained in your post. The literal must be surrounded in either single- or double-quotes suffixed with a "D" character.

You have a wealth of SAS documentation and supplemental technical / conference papers available at the SAS support http://support.sas.com/ website using its SEARCH facility or with a GOOGLE search.

Scott Barry
SBBWorks, Inc.

Using SAS® Dates and Times – A Tutorial
Jonas V. Bilenas, JP Morgan Chase, Wilmington, DE
http://www2.sas.com/proceedings/forum2007/226-2007.pdf

Entering Dates
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001397901.htm

Working with Dates in the SAS System
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm
Ask a Question
Discussion stats
  • 1 reply
  • 99 views
  • 0 likes
  • 2 in conversation