data sales;
input product $ date :date9. sales;
format date date9.;
datalines;
a 1Jan2012 200
b 4Jan2012 300
c 2Feb2012 200
d 3Mar2012 200
d 5Mar2012 100
;
run;
proc summary data=have nway;
class product;
var date sales ;
output out=summary (drop=_:) sum=;
run;
proc sql;
select product,sum(sales) as total_salees
from have
group by product;
quit;
Required output using proc sql
Obs | product | date | sales |
---|---|---|---|
1 | a | 01JAN2012 | 200 |
2 | b | 04JAN2012 | 300 |
3 | c | 02FEB2012 | 200 |
4 | d | 06MAY2064 | 300 |
What are you trying to achieve with a sum of dates?
What is the question? You never explain, you just throw data at us and give us no clue about what you are doing; please stop doing this. Please ask clear questions from now on and give clear explanations of what you are doing and why you are doing it.
Please explain how input dates of
3Mar2012
5Mar2012
become
06MAY2064
in your "required output using proc sql".
Really? You want a date that is 50 or more years later than the dates given??? And in a different month?
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!
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.