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

Hello,

 

I am trying to create a graph where the x axis will be time CD4 count was measured (before diagnosis, at diagnosis, 2 months after diagnosis, 4 month after diagnosis, 8 months after diagnosis and 10 months after diagnosis) and y axis will be the CD4 count. I want to label the grid values so that I can see: "before diagnosis", "2 months", "4 months" and so on on the x-axis. The partial code I want to use is below. How do I achieve the formatting of the "Time of CD4 measurement" values in the graph? 

 

proc sgplot data=one;

panelby state;

refline 0/ axis=x lineattrs=(color= red pattern=2);

series x=time y=CD4_count lineattrs=(color=gray pattern=1 thickness=1);

colaxis label= "Time of CD4 measurement" grid values= (0 to 10 by 1);

rowaxis label= "CD4_count"; run;

 

I appreciate any help you can offer

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

A user defined format works fine. 

Assuming you had used numbers instead:

 

proc format;
value time_measure_fmt
 1 = 'Before'
2  = 'At'
3 = 'After';
run;

Then apply it in SGPLOT

 

format time time_measure_fmt.;

@lousam wrote:

Hello,

 

I am trying to create a graph where the x axis will be time CD4 count was measured (before diagnosis, at diagnosis, 2 months after diagnosis, 4 month after diagnosis, 8 months after diagnosis and 10 months after diagnosis) and y axis will be the CD4 count. I want to label the grid values so that I can see: "before diagnosis", "2 months", "4 months" and so on on the x-axis. The partial code I want to use is below. How do I achieve the formatting of the "Time of CD4 measurement" values in the graph? 

 

proc sgplot data=one;

panelby state;

refline 0/ axis=x lineattrs=(color= red pattern=2);

series x=time y=CD4_count lineattrs=(color=gray pattern=1 thickness=1);

colaxis label= "Time of CD4 measurement" grid values= (0 to 10 by 1);

rowaxis label= "CD4_count"; run;

 

I appreciate any help you can offer


 

View solution in original post

3 REPLIES 3
Reeza
Super User

A user defined format works fine. 

Assuming you had used numbers instead:

 

proc format;
value time_measure_fmt
 1 = 'Before'
2  = 'At'
3 = 'After';
run;

Then apply it in SGPLOT

 

format time time_measure_fmt.;

@lousam wrote:

Hello,

 

I am trying to create a graph where the x axis will be time CD4 count was measured (before diagnosis, at diagnosis, 2 months after diagnosis, 4 month after diagnosis, 8 months after diagnosis and 10 months after diagnosis) and y axis will be the CD4 count. I want to label the grid values so that I can see: "before diagnosis", "2 months", "4 months" and so on on the x-axis. The partial code I want to use is below. How do I achieve the formatting of the "Time of CD4 measurement" values in the graph? 

 

proc sgplot data=one;

panelby state;

refline 0/ axis=x lineattrs=(color= red pattern=2);

series x=time y=CD4_count lineattrs=(color=gray pattern=1 thickness=1);

colaxis label= "Time of CD4 measurement" grid values= (0 to 10 by 1);

rowaxis label= "CD4_count"; run;

 

I appreciate any help you can offer


 

lousam
Obsidian | Level 7

Thank you. Sorry, I made a mistake I meant to use procsgpanel in my question. I am using a macro where my data set varies (4 data sets total) but the variables and the code remains the same as the one I listed in the previous question. For some reason using the format statement isn't working (can't see the formatted time values). Thank you again

ballardw
Super User

1) don't see a FORMAT statement in the Proc SGPLOT/ SGPANEL code.

If the format is not permanently associated with the variable you need a statement such as

 

Format time <formatname.>;

 

2) We would likely need to see actual values of X and your format definition to diagnose anything further.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 7395 views
  • 0 likes
  • 3 in conversation