I have performance dataset in excel spreadsheet for companies in 50 states from Jan 2009.Each state have 2 or more companies and I have several performance metrices like profit amount, turnover rate , quantity used etc.
Date State Company Profit amount Turnover rate Quantity
July 2009 CA aaa 5,000$ 20% 35
Bbb 8,000$ 55% 42
I add new data for each state and company every month. I need to create charts for the past 18 months of data .
I tried to use month(today()) as current month (start date) and month(today())-12 as end date but it is not working.
Also how can I write a macro so that state I can import the data file every month and replace the old data set in sas and create state as macro variable so that I can type the required state and it will display the corresponding state data and then I can create the chart for the corresponding state?
I am new to the macros.
Any suggestion would be appreciated.
A couple of things to help you out. The first is using the INTNX function to define the date range. First off you want to create macro variables representing the past 12 months ending last month (since the current month is not complete):
You now have two macro variables representing the first day of the previous and 12 months ago.
To subset the data for a single state and the time period is simple;
Assumption is that the dta has been imported into SAS table PERFORMANCE.
where state="&state" and intnx('month',date,0) between &prev12_month and &prev_month;
/* Insert chart code here */
This will create a SAS table named California containing CA records for the past 12 months. If you insert chart code you can create a chart with the macro.
There are ways that you can build charts for all possible combinations of state and company by identifying unique combinations and then running them through a do loop. Hope this gets you in the right direction.