Hi everyone, first-time poster here!
So I have this data set:
This is my data
It produced a series plot like this:
and this is the plot I got
I want my graph to look like this with the x-axis to consist only year, obviously i failed using the SAS code below because the x-axis looks right but there's no graph.
I want the plot to have the x-axis like this (obviously I failed, the graph does not appear)
this is what I used
Please help 😞
Your INPUT statement seems wrong. You are defining DATE as character and then trying to attach numeric format and informat to it. That will produce notes in the log.
241 format date MONYY7.; ------- 484 242 informat date MONYY7.; ------- 485 NOTE 484-185: Format $MONYY was not found or could not be loaded. NOTE 485-185: Informat $MONYY was not found or could not be loaded.
Try:
input date :anydtdte. open high low close adj_close vol;
format date MONYY7.;
I can't edit your code because you provided a picture.
Try this for your xaxis statement:
Xaxis values=('01Jan2010'd to '01Jan2020'd by year) valuesformat=year4.;
ANY time you want to reference a specific value for a date value you must reference it as a quoted date9. or date7. value followed by d. The d tells SAS you want it treated as a date. The Date9 or Date7 because any other series of 6 or 8 digits might represent dates but only in a specific interpretation. The VALUESFORMAT option allows you to override the default format for the values that appear for tick marks on an axis.
In the future please provide code or text from log entries by copying from the editor or log and pasting into a code box opened on the forum with the </> icon. The message windows will reformat text.
Data is best provided as data step code. We cannot write code that will read a picture as data.
Hi, thank you for your quick response, i've tried to put your SAS code in like below:
ods html close;
ods html;
data tesla;
infile "/folders/myfolders/TSLA (2).csv" delimiter=',' firstobs=2;
input date $ open high low close adj_close vol;
format date MONYY7.;
informat date MONYY7.;
proc print data=tesla;
ods graphics on;
proc sgplot data=tesla;
series x=date y=open;
Xaxis values=('01Jan2010'd to '01Jan2020'd by year) valuesformat=year4.;
title 'TSLA Opening Price';
run;
and it still doesn't work, this is the graph I got
Do you have any other suggestions? Thank you!
If I submit this code
proc sgplot data=SASHELP.STOCKS;
where Stock="IBM";
series x=date y=open;
run;
I get results, along the lines of this:
Output 10.1.1 - SAS Help Center: Example 10.1 Analysis of Stock Prices
What do you get? Perhaps this will inform us somehow of what's going on.
Your INPUT statement seems wrong. You are defining DATE as character and then trying to attach numeric format and informat to it. That will produce notes in the log.
241 format date MONYY7.; ------- 484 242 informat date MONYY7.; ------- 485 NOTE 484-185: Format $MONYY was not found or could not be loaded. NOTE 485-185: Informat $MONYY was not found or could not be loaded.
Try:
input date :anydtdte. open high low close adj_close vol;
format date MONYY7.;
Thank you so much! Your code works, I was only taught by my teachers the dollar sign is for "non-numerical" input so I didn't know this 😞
Why is there a "dollar sign" in you INPUT statement? Is that it? Is your date is a string?!
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.