Hello,
I got the following output after performing a frequency procedure and transposing by month.
Later, i want to create a grand_total on the resultant dataset like shown.
is it acheived by using an array?
Month Jan Feb mar apr may jun jul grand_total
Male 6 4 3 8 8 0 . 29
Female 4 4 7 7 0 . . 22
Thanks
Either use a reporting procedure from the start or calculate sum manually, but an array declaration isn't useful in this situation unless you're going to use it more than once or if you need some dynamic summation.
You can use variable lists without explicitly declaring an array.
Grand_total = sum (of JAN--JUL);
Grand_total = sum(of month1-month7);
No need for arrays just use the sum function e.g.
grand_total=sum(jan, feb, mar, apr, may, jun, jul);
Either use a reporting procedure from the start or calculate sum manually, but an array declaration isn't useful in this situation unless you're going to use it more than once or if you need some dynamic summation.
You can use variable lists without explicitly declaring an array.
Grand_total = sum (of JAN--JUL);
Grand_total = sum(of month1-month7);
Thanks Reeza,
The double dashes works fine like shown below in a seperrate data step after the proc transpose.
But putting a single dash inbetween doent work only considers the two months.
Grand_total = sum(of Feb2016--Feb2017);
Thanks again
You can only use single dashes if you have a series of variables with an index, as in the example. And I believe this behaviour changed in 9.3
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.