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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.