BookmarkSubscribeRSS Feed
aczech2001
Calcite | Level 5

Hi to all,

Another probably rather an easy question. How to produce an interval plot for Age x Response type (variable RESP), or for credit score (CRED)xRESP- data attached.

 

First I produced a box plot with the 'Tasks and Utilities'>>Tasks>>Graphs>>Box Plot

And I was trying to fiddle with the code using SAS help, infering the following advice

proc sgplot data=confidence;
  scatter y=var x=mean / xerrorlower=lowerci xerrorupper=upperci
          markerattrs=(symbol=circlefilled size=9);
  run;

 

But the final result is only an error.

 

Please, could you advice how should I create the interval plot using the code.

 

Data attached.

 

Thank you again for everyone's help,

 

Agnieszka

8 REPLIES 8
Reeza
Super User
What error are you getting? Include the full log. From a quick glance I don't see any issues with your code.
ballardw
Super User

@aczech2001 wrote:

Hi to all,

Another probably rather an easy question. How to produce an interval plot for Age x Response type (variable RESP), or for credit score (CRED)xRESP- data attached.

 

First I produced a box plot with the 'Tasks and Utilities'>>Tasks>>Graphs>>Box Plot

And I was trying to fiddle with the code using SAS help, infering the following advice

proc sgplot data=confidence;
  scatter y=var x=mean / xerrorlower=lowerci xerrorupper=upperci
          markerattrs=(symbol=circlefilled size=9);
  run;

 

But the final result is only an error.

 

Please, could you advice how should I create the interval plot using the code.

 

Data attached.

 

Thank you again for everyone's help,

 

Agnieszka


1) An Excel spreadsheet is not actually SAS data as choices have to be made as to type of variable (numeric or character) which are not obvious in Excel. Provide data step code that actually creates a SAS data set to provide an example such as:

data have;
input AGE	CRED 	MS $	INCOME	MOB $	MILEAGE	RESTYPE $	GENDER $	Kids	MRTGI $	resp	cuscode;
datalines;
20	543	U	20	Y	14.42	HOME	M	0	N	0	1
18	445	U	20	Y	0.31	HOME	M	2	Y	0	2
19	423	U	20	N	17.88	HOME	M	1	Y	0	3
18	416	X	20	Y	17.08	HOME	F	0	Y	0	4
18	522	U	20	Y	16.51	HOME	F	1	Y	0	5
19	467	U	20	N	16.24	HOME	F	0	Y	0	6
;
run;

That will provide something we can test code against.

 

Your example data should only include variables needed for the actual question. I copied the first few rows of you example data

because:

2) You show code using variables named VAR MEAN LOWERCI and UPPERCI.  There is nothing in the attached file with those column headings or names. So we can not determine from your "code" what you attempted with the example "data".

aczech2001
Calcite | Level 5
I worked that out. it is just an example copied from the PDF offered by SAS.

The thing is that we have tried to fiddle with colleagues the variables around. Nothing constructive comes up with it, apart from very extreme graphs that do not depict any whiskers, medians etc.

Thus, please would you mind running the data I provided, and creating an interval plot for age x resp variables, and posting the code to the forum?

Thanks

Agnieszka
ballardw
Super User

@aczech2001 wrote:
I worked that out. it is just an example copied from the PDF offered by SAS.

The thing is that we have tried to fiddle with colleagues the variables around. Nothing constructive comes up with it, apart from very extreme graphs that do not depict any whiskers, medians etc.

Thus, please would you mind running the data I provided, and creating an interval plot for age x resp variables, and posting the code to the forum?

Thanks

Agnieszka

You will have to use your data to calculate the Mean and the upper and lower confidence limits with a procedure such as Proc means or summary for the combinations of the grouping variables and each of your "response variables".

 

I cannot tell what you want for an x-axis.

 

 

Reeza
Super User




@aczech2001 wrote:



Thus, please would you mind running the data I provided, and creating an interval plot for age x resp variables, and posting the code to the forum?

Thanks

Agnieszka

 

 

If you need someone to do work for you, it is better to hire a contractor. This forum is for support and help, not to do work on demand. You haven't shown the errors your code is generating, which was asked for in my previous response. Or provided an example of what you want. You've referred to box plots and medians/whiskers but an interval plot is usually mean and 95% CI unless I'm mistaken. It's also possible to do a similar styled plot with Median and 5/95% percentiles as well. 

 

 

1. Use proc means (or any summary procedure) and calculate the upper and lower CI -> create an output data set with these values

2. Use SGPLOT and the output data set from #1 to create your graph

 

All of this can easily be done from the GUI interface or via code. If you've attempted this many times with colleagues already, please post your closest version with the errors from the log. Please show the full code you've tried so far.

 

If you're trying to show this for a whole bunch of variables that have different scales that won't make sense because the scales are so far off that only the biggest one will likely show up and the remaining will show up with just the lines or dots. 

 




 

aczech2001
Calcite | Level 5

Thanks for your reply, but that's rather rude. yes, on the other hand, thanks for your efforts in giving a hint.

 

I have posted the errors above: there should be somewhere in the link.

 

I am asking in this way because I have never had an experience with writing any codes, and I still don't know a single command. and reading the 'advice' available online is really confusing because each case if different. So I am trying to work out whats going on, I am not being paid for any job, as I am a student.

 

Maybe if you feel like being rude to someone who tries to learn, maybe it is better not to answer at all? And leave it to someone who wants to give some idea. Thanks for cooperation! 

 

I think it is a simple task and no one is loosing any intellectual rights pasting a code for a very simple operation.

 

BW

 

Agnieszka

 

 

 

Reeza
Super User
You stated you tried with colleagues (your words, not mine) and had various attempts. Yes, I could code up an answer but I’m confused at your hesitancy to post your log or attempts.
I’m very happy to help which you’ve seen with your first few questions where I literally told you what to click and where, but when you phrase your response as as ‘please just give me the answer’ (my words) isn’t particularly polite either, even with a please. I’ll remove myself from your questions if you;d like. Good Luck.
Rick_SAS
SAS Super FREQ

It's not clear whether you are asking how to GET the data to plot or whether you are asking a pure graphics question. If you have the data and want to plot it, see the following examples. Maybe one will be similar to your application.

Odds ratio plots

Regression coefficient plots

Forest plots

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
  • 8 replies
  • 1611 views
  • 0 likes
  • 4 in conversation