BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vasundha
Calcite | Level 5

Hi Everyone.

I created a line chart in sas eg by taking a table as input which has date values of every Monday to Thursday. When I take last 7 days data from that table, I was getting non existing date values in my report also. Could anyone please help me out to get rid of them. Thanks. I've attached the sample report of it. As you see the below attached report, actually I don't have 11Nov, 12, 13 in my input table but still I was getting them that shouldn't happen.

Here's my code for line chart proc sgplot:

Proc sgplot data=have nocycleattrs;
Series x = dates y= A / lineattrs=(color=blue);
Series x = dates y= B / lineattrs=(color=green);
Series x = dates y= C / lineattrs=(color=red);
run;

IMG_20221121_165526.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Your posted data does not contain the variables from the posted PROC SGPLOT Code. 

 

However, I interpret your problem like this. You do not have 11, 12, 13 Nov in your data. So you do not want to display them in your graph. 

 

You can add the line below in your code to achieve this.

 

xaxis type = discrete;

View solution in original post

8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

Can you attach some sample data? Makes it easier to help you.

Vasundha
Calcite | Level 5

Sure here it is : 

Data have;
Input in_date : date9. readings;
format in_date date9.;
Datalines;
08Nov2022 89
09NOV2022 61
10NOV2022 60
14NOV2022 53
15NOV2022 45
16NOV2022 15
17NOV2022 12
;
run;
Kurt_Bremser
Super User

This is not the dataset you use in your SGPLOT procedure, none of the variables used in the plot are there. Please post the real dataset with variables dates, a, b and c.

Vasundha
Calcite | Level 5

Extremely Sorry here it is. 

Data have;
Input dates : date9. A B C;
format dates date9.;
Datalines;
08Nov2022 89 468  120
09NOV2022 61 345 287
10NOV2022 60 900 111
14NOV2022 53 127 123
15NOV2022 45 460 430
16NOV2022 15 230 550
17NOV2022 12 310 589
;
run;
PeterClemmensen
Tourmaline | Level 20

Your posted data does not contain the variables from the posted PROC SGPLOT Code. 

 

However, I interpret your problem like this. You do not have 11, 12, 13 Nov in your data. So you do not want to display them in your graph. 

 

You can add the line below in your code to achieve this.

 

xaxis type = discrete;
Vasundha
Calcite | Level 5

It worked, please fill your heart heartily thanked. 

PeterClemmensen
Tourmaline | Level 20

Heartily filled 🙂

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1165 views
  • 1 like
  • 3 in conversation