06-11-2013 04:00 AM
I have a data sample that looks loke this:
Month Name Income
January Mary 1543
February Mary 1654
March Mary 1578
January Joan 2345
February Joan 2378
March Joan 2350
January Hillary 3567
February Hillary 3678
March Hillary 3456
I want to see the trend for "Income" for each person considering the data from each month. In Excel I could do a graph for each one and use the option "Add trendline". This is just an example, but I have a larer database for which I need to do it. Is there any possibility to do it using SAS? I do not necessarily need a graphic, a result like "ascending" or "descending" would be enough.
Thank you in advance.
06-11-2013 08:13 AM
Try the following code. It's more complicated than usual because your variable, MONTH, is a character variable
that may not be compatible with a variable specified in the PLOT statement of PROC GPLOT.
Another alternative would be a linear regression using PROC REG, regressing income on month, and looking for
positive, neutral, or negative regression coefficients for month.
* Formats for month variables;
value $monthfm "January"="1" "Februrary"="2" . . . "December"="12";
value month 1="January" 2="February" . . . 12="December";
* Convert month-names to numbers from 1 to 12;
* Sort data by name and number of month;
proc sort data=new equals;
by name monthnum;
* Plot income vs. month and interpolate a linear regression line;
* for each name;
symbol1 v=plus i=rl;
proc gplot data=new;
format monthnum month.;