BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
turcay
Lapis Lazuli | Level 10

I have data similar to the first image below. Second image has the graph created with these data. It was created in Excel. What do i need to create the same image using the same data on SAS? Can you help me please?

 

Matris.png

 

Matris2.png

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Convert your data from the wide matrix format to a long format with three columns:

X  Y  Z

1  1  0.5509

1  2  0.0801

1  3  0.0678

...

44 44 0.5263

 

proc template;
  define statgraph SurfaceTmplt; 
   begingraph;
    entrytitle "My Graph Title";
    layout overlay3d;
      surfaceplotparm x=x y=y z=z / 
        surfacetype=fill;
    endlayout; 
   endgraph;
  end;
run;

proc sgrender data=MyData template=SurfaceTmplt;
run;

 

See the documentation for the SURFACEPLOTPARM statement to se how to modify the colors of the surface by using the COLORESPONSE= and COLORMODEL= options.

View solution in original post

9 REPLIES 9
Reeza
Super User
As mentioned before it helps if you post data as text rather than an image. Look into proc g3d.
turcay
Lapis Lazuli | Level 10

Hello Reeza,

 

I could not add Excel file related to Surface Chart . But i added datas as SAS Code below. But it is not the same data that i posted my first message. I tried to generate sample data for your helping. I believe you can benefit from this data.

 

Thank you.

 

	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16	17	18	19	20	
1	0.29	0.22	0.15	0.09	0.05	0.05	0.04	0.02	0.02	0.02	0.01	0.01	0.01	0.01	0.01	0.01	0.00	0.00	0.00	0.00	100%
2	0.18	0.38	0.18	0.10	0.02	0.02	0.02	0.02	0.01	0.01	0.01	0.01	0.00	0.01	0.01	0.01	0.01	0.00	0.00	0.00	100%
3	0.09	0.35	0.17	0.22	0.09	0.04	0.04	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	100%
4	0.03	0.03	0.35	0.34	0.17	0.03	0.03	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	100%
5	0.02	0.04	0.09	0.17	0.28	0.17	0.09	0.04	0.02	0.02	0.02	0.02	0.02	0.02	0.00	0.00	0.00	0.00	0.00	0.00	100%
6	0.02	0.02	0.02	0.07	0.14	0.43	0.18	0.09	0.02	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	100%
7	0.02	0.02	0.04	0.04	0.09	0.09	0.27	0.11	0.09	0.04	0.05	0.04	0.04	0.02	0.02	0.02	0.02	0.00	0.00	0.00	100%
8	0.00	0.00	0.00	0.00	0.00	0.05	0.20	0.49	0.15	0.05	0.05	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	100%
9	0.00	0.00	0.00	0.02	0.04	0.04	0.10	0.10	0.35	0.16	0.08	0.04	0.04	0.02	0.00	0.00	0.00	0.00	0.00	0.00	100%
10	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.04	0.19	0.36	0.34	0.04	0.04	0.00	0.00	0.00	0.00	0.00	0.00	0.00	100%
11	0.00	0.00	0.00	0.00	0.00	0.02	0.04	0.04	0.09	0.09	0.29	0.11	0.09	0.06	0.04	0.04	0.04	0.04	0.02	0.00	100%
12	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.08	0.16	0.43	0.16	0.08	0.08	0.00	0.00	0.00	0.00	0.00	100%
13	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.03	0.03	0.09	0.18	0.26	0.28	0.09	0.03	0.00	0.00	0.00	0.00	100%
14	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.04	0.06	0.10	0.17	0.31	0.13	0.10	0.06	0.04	0.00	0.00	100%
15	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.02	0.02	0.04	0.04	0.09	0.09	0.17	0.30	0.11	0.06	0.02	0.02	0.02	100%
16	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.06	0.11	0.13	0.37	0.15	0.11	0.04	0.04	100%
17	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.04	0.26	0.32	0.21	0.13	0.04	100%
18	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.02	0.02	0.02	0.04	0.04	0.04	0.08	0.08	0.14	0.33	0.10	0.10	100%
19	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.04	0.04	0.08	0.16	0.32	0.16	0.20	100%
20	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.04	0.08	0.16	0.36	0.37	100%

 

Matris.png

Rick_SAS
SAS Super FREQ

Convert your data from the wide matrix format to a long format with three columns:

X  Y  Z

1  1  0.5509

1  2  0.0801

1  3  0.0678

...

44 44 0.5263

 

proc template;
  define statgraph SurfaceTmplt; 
   begingraph;
    entrytitle "My Graph Title";
    layout overlay3d;
      surfaceplotparm x=x y=y z=z / 
        surfacetype=fill;
    endlayout; 
   endgraph;
  end;
run;

proc sgrender data=MyData template=SurfaceTmplt;
run;

 

See the documentation for the SURFACEPLOTPARM statement to se how to modify the colors of the surface by using the COLORESPONSE= and COLORMODEL= options.

turcay
Lapis Lazuli | Level 10

Hello Rick,

 

Your code helped me a lot. It created the report which i wanted but i took "ERROR: Template 'SurfaceTmplt' was unable to write to template store!". I would like to learn why i took this error message. Could you inform me ,please ?

 

Thank you.

 

Rick_SAS
SAS Super FREQ

It's hard to say. I sometimes encounter that error when I am running multiple copies of SAS and one copy has locked the template that another is trying to access. 

 

You only need to write the template once, so if you can create the graph you don't need to resubmit the PROC TEMPLATE code every time.

 

How are you running SAS? Enterprise Guide? SAS Studio? Stand-alone Windowing environment (DMS)?

turcay
Lapis Lazuli | Level 10

So if i resubmit the code i will get the error again everytime. I'm running SAS by using EG.

Rick_SAS
SAS Super FREQ

I didn't say that. Under normal conditions the template will be overwritten and replaced every time you resubmit.  But since you are having problems, you can make the error go away by commenting out the PROC TEMPLATE code.

 

I don't know what the problem is, but the first thing I'd do it to exit EG and then restart it. Maybe the template got corrupted or locked when you were developing the program. Hard to say what is going on without more information.

turcay
Lapis Lazuli | Level 10

Thank you Rick,

 

I closed the all SAS sessions then i reopen my Surface session on EG and it works, thanks a lot. But i have a problem related to provide the same image(report) on SAS which i founded on Excel. I performed your method but i couldn't created the same report. I attached the datas which i both created on SAS and Excel. Could you inform me what am i doing wrong,please ?  Am i missing something ?

 

Thank you.

turcay
Lapis Lazuli | Level 10

Can somebody help me out ? I would like to know why i couldn't get the same value on SAS.

 

Thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 2137 views
  • 0 likes
  • 3 in conversation