[using EG 9.4]
I have a data set that looks like this:
product sale_date price abc 01/01/2018 1.13 abc 06/01/2018 1.29 abc 02/02/2018 1.23 xyz 02/01/2018 1.54 xyz 08/01/2018 1.58 xyz 03/02/2018 1.41
And I need to plot two series (one for each product) on a pbspline plot of "price vs date".
I have tried a number of variations but am unable to get two separate series. Here's what I used most recently:
ods graphics on / height=600 width=900 noborder;
proc sgplot data=work.product_daily_sales(where=(product IN ('abc', 'xyz')));
by product;
pbspline x=sale_date y=price / legendlabel='company1' markerattrs=(symbol=circle color=blue size=5) lineattrs=(color=blue);
pbspline x=sale_date y=price / legendlabel='company2' markerattrs=(symbol=circle color=red size=5) lineattrs=(color=red);
xaxis label='Date';
yaxis label='US Price ($)';
title 'Sales Price by date of sale';
run;
quit;
Basically, I am comparing prices for a similar product to two different companies and I need to show the difference in pricing on the one graph.
The above code gets me closest to what I want but displays two graphs.
Can anyone help?
Thanks in advance.
ods graphics on / height=600 width=900 noborder;
proc sgplot data=work.product_daily_sales(where=(product IN ('abc', 'xyz')));
pbspline x=sale_date y=price / group=product markerattrs=(symbol=circle color=blue size=5) lineattrs=(color=blue);
xaxis label='Date';
yaxis label='US Price ($)';
title 'Sales Price by date of sale';
run;
@chuckd wrote:
[using EG 9.4]
I have a data set that looks like this:
product sale_date price abc 01/01/2018 1.13 abc 06/01/2018 1.29 abc 02/02/2018 1.23 xyz 02/01/2018 1.54 xyz 08/01/2018 1.58 xyz 03/02/2018 1.41And I need to plot two series (one for each product) on a pbspline plot of "price vs date".
I have tried a number of variations but am unable to get two separate series. Here's what I used most recently:
ods graphics on / height=600 width=900 noborder; proc sgplot data=work.product_daily_sales(where=(product IN ('abc', 'xyz'))); by product; pbspline x=sale_date y=price / legendlabel='company1' markerattrs=(symbol=circle color=blue size=5) lineattrs=(color=blue); pbspline x=sale_date y=price / legendlabel='company2' markerattrs=(symbol=circle color=red size=5) lineattrs=(color=red); xaxis label='Date'; yaxis label='US Price ($)'; title 'Sales Price by date of sale'; run; quit;
Basically, I am comparing prices for a similar product to two different companies and I need to show the difference in pricing on the one graph.
The above code gets me closest to what I want but displays two graphs.
Can anyone help?
Thanks in advance.
ods graphics on / height=600 width=900 noborder;
proc sgplot data=work.product_daily_sales(where=(product IN ('abc', 'xyz')));
pbspline x=sale_date y=price / group=product markerattrs=(symbol=circle color=blue size=5) lineattrs=(color=blue);
xaxis label='Date';
yaxis label='US Price ($)';
title 'Sales Price by date of sale';
run;
@chuckd wrote:
[using EG 9.4]
I have a data set that looks like this:
product sale_date price abc 01/01/2018 1.13 abc 06/01/2018 1.29 abc 02/02/2018 1.23 xyz 02/01/2018 1.54 xyz 08/01/2018 1.58 xyz 03/02/2018 1.41And I need to plot two series (one for each product) on a pbspline plot of "price vs date".
I have tried a number of variations but am unable to get two separate series. Here's what I used most recently:
ods graphics on / height=600 width=900 noborder; proc sgplot data=work.product_daily_sales(where=(product IN ('abc', 'xyz'))); by product; pbspline x=sale_date y=price / legendlabel='company1' markerattrs=(symbol=circle color=blue size=5) lineattrs=(color=blue); pbspline x=sale_date y=price / legendlabel='company2' markerattrs=(symbol=circle color=red size=5) lineattrs=(color=red); xaxis label='Date'; yaxis label='US Price ($)'; title 'Sales Price by date of sale'; run; quit;
Basically, I am comparing prices for a similar product to two different companies and I need to show the difference in pricing on the one graph.
The above code gets me closest to what I want but displays two graphs.
Can anyone help?
Thanks in advance.
Thanks. I was almost there.
In cases like this, how do you change the marker and line attributes of the different series (products in this case)? So they're both not in blue.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.