BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
thuphammm
Fluorite | Level 6

Hi everyone, first-time poster here!

So I have this data set:

This is my dataThis is my data

It produced a series plot like this:

and this is the plot I gotand 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)I want the plot to have the x-axis like this (obviously I failed, the graph does not appear)this is what I usedthis is what I used

Please help 😞 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.;

 

View solution in original post

7 REPLIES 7
ballardw
Super User

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.

thuphammm
Fluorite | Level 6

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

Screen Shot 2021-03-26 at 13.27.37.png

 

Do you have any other suggestions? Thank you!

 

Ksharp
Super User
Try to change your format.

input date $ open high low close adj_close vol;
format date MONYY7.;

----->
input date $ open high low close adj_close vol;
format date year4.;
PhilC
Rhodochrosite | Level 12

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.

Tom
Super User Tom
Super User

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.;

 

thuphammm
Fluorite | Level 6

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 😞 

PhilC
Rhodochrosite | Level 12

Why is there a "dollar sign" in you INPUT statement?  Is that it?  Is your date is a string?!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1389 views
  • 3 likes
  • 5 in conversation