Reporting period

10 pts.
Tags:
SAS
SAS 9.2
Need help to create 12-month running total by customer_id which include the following: 1. MonthlyTotal 2. Monthly Percentage, 3. Previous Month total, 3. YTD 4 . YTD Percentage Below is an example of what I am trying to accomplish. Within the example there are customer_id , 24 and 25. Each row of data represents one month along with sales amount. The variable I would like to calculate is the "sales_amout", which is the 12 month running total within the customer_id. As you can see, the first 12 "sales_amount" is blank because there hasn't been 12 months of data yet. this Data table for example is a short list of 12 months of data: customer_id Month Sales_Amount 23 01JAN2013 23 02JAN2013 23 03JAN2012 24 01DEC2012 10.00 . 24 02DEC2012 30.00 24 03DEC2012 50.00 Here is my code and code is not working: ``` Data TOTAL_SALES; Set SALES; /** allows first. and last. processing **/ By customer_id month prev_month; RETAIN total 0 monthTotal 0 month1 – month12 prevmonth_tot 0; if sales_amount = . then delete; /* month 1 though month 12*/ ARRAY sales_amount {12} \$ month1-month12; IF first.sales_amount THEN do; do i = 1 to 12; sales(i)=''; end; end; n+1; sales(n)=sales_amount; IF last.customer_id THEN do n=0; output; end; /*Month Total*/ month_total + sale_amount; total + sale_amount; total = sum(of month1 – month12); total + sales_amount if FIRST.customer_id then monthTotal = 0 ; if LAST.customer_id then output ; /*Month Percentage*/ month/month pct=sales_amount/total /*previous month*/ Array mths {12} month1 – month12; do i = 2 to 12; index1 = month(date); /** extract month from date value **/ mths{index1} = mths{index1} + sales_amount; if first.customer_id{i} then do prevmonth_tot{i} =0; if Last.customer_id{i} then output; /*YTD*/ Array months {12} month1 – month12; index2 = month(date); /** extract month from date value **/ months{index} = months{index} + sales_amount; if last.customer_id then do; /** last observation for customer **/ YTD_total = sum(of month1 – month12); /** year-to-date total **/ output; /** output one observation per customer **/ do i = 1 to 12; months{i} = 0; /** reset to zero for next customer **/ end; end; /*YTD* Percentage*/ do i=12; ytd = (i)/total Software/Hardware used: sas ```
``` Asked: January 28, 2013  12:52 PM Last updated: January 28, 2013  6:57 PM ```
``` ```
``` ```
``` Related Questions Subquery in Microsoft Access Cobol, DB2, and DDS Report S_ALR_87013602 Copy data from an entire row in Excel 2003 sheet to another sheet in the same workbook automatically Query400 report generation ```
``` ```
``` var answerObject = new Answer_Class(); answerObject.initialize("answerObject", "answerObject", 278562,102, 122); Answer Wiki Thanks. We'll let you know when a new response is added. Send me notifications when members answer or reply to this question. Register Hereor login if you are already a member E-mail User Name Password Forgot Password? By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy var commentObject = new Itkerepo_Class(); commentObject.initialize("commentObject", "stub_comments", "comments", "278522", "", "6cd4282923", 102, 1, 122); Discuss This Question:     There was an error processing your information. Please try again later. Thanks. We'll let you know when a new response is added. Send me notifications when members answer or reply to this question. Register Hereor login if you are already a member E-mail User Name Password Forgot Password? By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy <!-- function google_ad_request_done(google_ads) { var i; if(google_ads.length > 0) { document.write('<div class="googleAds_solid_roundCorners_5"> \n'); document.write ('<a href="https://www.google.com/adsense/support/bin/request.py?contact=abg_afc" target="new"><div class="googleAds_titleBar">ADS BY GOOGLE</div></a> \n'); document.write('<div class="googleAds_innerTube">'); for(i = 0; i < google_ads.length; ++i) { document.write('<!-- begin ad -->'); document.write('<strong>' + google_ads[i].line1 + '</strong> - '); document.write(google_ads[i].line2); document.write(' ' + google_ads[i].line2 + ' '); document.write(' ' + google_ads[i].line3 + ' '); document.write('<br/><a href="' + google_ads[i].url + '" target="new">' + google_ads[i].visible_url + '</a>'); document.write('<br class="height5" /><br/>'); } document.write('</div>'); document.write('</div>'); } } // --> <!-- google_ad_client = 'ca-pub-6050985421795229'; google_ad_channel = 'itke'; google_ad_output = 'js'; google_max_num_ads = 5; // --> ```
``` Ask a Question Question Title: (150 char. limit.) Question: (Please be specific.) Tags: (Separate with commas.) What is a Tag? jQuery( document ).ready( function( \$ ) { var ajaxurl = 'wp-admin/admin-ajax.php?action=tt_autosuggest_cats'; var data = { multiple:true, multipleSep: "," }; jQuery("#post_category").suggest(ajaxurl, data); } ); Ask Question GPT(function () { var slot = this.googletag.defineSlot(this.unitName, [[300,250]], "div-gpt300x250"); slot.display(); }); GPT(function () { var slot = this.googletag.defineSlot(this.unitName, [[300,600]], "div-gpt300x600"); slot.display(); }); Free Guide: Managing storage for virtual environments Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content! Browse by Topic AS/400 Business Intelligence Career Development Channel Cloud Computing Compliance Consumerization Content Management CRM Data Management Database DataCenter Desktop Management Development Email Administration Hardware IT Strategy Linux Lotus Domino Marketing Microsoft Exchange Microsoft Windows Mobile Networking Oracle Productivity Software SAP Security SQL Server Storage Systems Management Virtualization VoIP Windows Server >>VIEW ALL TAGS tech target logo About Us Contact Us FAQ Community Blog TechTarget Corporate Site Terms of Use DMCA Policy Privacy Policy Questions & Answers Index 1 Questions & Answers Index 2 Discussions Index IT Topics Index 1 IT Topics Index 2 Blog Index All Rights Reserved, copyright 2000 - 2018, TechTarget ```
``` var _sf_async_config={}; /** CONFIGURATION START **/ _sf_async_config.uid = 41935; _sf_async_config.domain = 'techtargetnetwork.com'; _sf_async_config.useCanonical = true; _sf_async_config.sections = 'ITKE, ITKE - Business Intelligence'; _sf_async_config.authors = 'dfayen, Answers, ITKE - Answers' ; /** CONFIGURATION END **/ (function(){ function loadChartbeat() { window._sf_endpt=(new Date()).getTime(); var e = document.createElement('script'); e.setAttribute('language', 'javascript'); e.setAttribute('type', 'text/javascript'); e.setAttribute('src', (('https:' == document.location.protocol) ? 'https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/' : 'http://static.chartbeat.com/') + 'js/chartbeat.js'); document.body.appendChild(e); } var oldonload = window.onload; window.onload = (typeof window.onload != 'function') ? loadChartbeat : function() { oldonload(); loadChartbeat(); }; })(); jQuery(document).ready(function() { \$("#answerWiki").clEditorUXenhancements("#answerWiki", "Add your answer..."); });jQuery(document).ready(function() { \$(".readArticle.col, .discussArticle.col").equalHeights(); }); \$(document).ready(function() { \$('.readArticle.col, .discussArticle.col').equalHeights(); \$('body').tooltip(); \$('#comments').expandSetNumber('#comments', commentObject.total_comments, '.repliesContainer', commentObject.total_comments, 'Reply'); }); jQuery(document).ready(function() { \$("form .cleditorMain iframe").addClass("required"); \$("#comments").clEditorUXenhancements("#comments", "Add your reply..."); \$("#discussions").clEditorUXenhancements("#discussions", "Add your reply..."); }); ```