Hello all,
I expect to create a figure
for the following data,
data have;
INFILE CARDS DSD DLM=',';
input
CTRY :$10.
INDUSTRY :$29.
R&D :8
PATENTS :8
;
cards;
AT,Manufacure,4316550,2033058
AU,Manufacure,2701929,961452
BE,Manufacure,1935804,564041
AT,Service,2069617,483619
AU,Service,1058213,235353
BE,Service,1024675,60304
AT,Oil,1725920,242679
AU,Oil,2178870,543554
BE,Oil,1024675,60304
;
run;
I expect to create three X Y scatter for each INDUSTRY
I would like to put the value of "R&D" at Y-axis and value of "Patent" at X-axis and the value of "INDUSTRY" as the title of each scatter. SO the value of each country is expected to be displayed as a point on each scatter chart.
Could you please give me some suggestion about this?
thanks in advance.
For three plots in one image, you will want to use Proc SGPANEL.
Proper data is important, the sample in your question does not input properly. The sample code below fixes the input:
data have; attrib country_code length=$2 industry length=$20 label = "INDUSTRY" rnd format=dollar12. label = 'R & D' patents format=dollar12. label = 'Patent' ; INFILE CARDS DSD DLM=','; input country_code industry rnd patents; datalines; AT,Manufacture,4316550,2033058 AU,Manufacture,2701929,961452 BE,Manufacture,1935804,564041 AT,Service,2069617,483619 AU,Service,1058213,235353 BE,Service,1024675,60304 AT,Oil,1725920,242679 AU,Oil,2178870,543554 BE,Oil,1024675,60304 ; proc sgpanel data=have; panelby industry / columns=1; scatter x=patents y=rnd / datalabel=country_code; run;
Have you tried the first example in SGPLOT documentation?
https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n06fb9ichgg6akn18060gbtvw9pw.htm&doc...
To split by industry instead of group it, use a BY statement and don’t use the GROUP option.
@Alexxxxxxx wrote:
Hello all,
I expect to create a figure
for the following data,
data have;
INFILE CARDS DSD DLM=',';
input
CTRY :$10.
INDUSTRY :$29.
R&D :8
PATENTS :8
;
cards;
AT,Manufacure,4316550,2033058
AU,Manufacure,2701929,961452
BE,Manufacure,1935804,564041
AT,Service,2069617,483619
AU,Service,1058213,235353
BE,Service,1024675,60304
AT,Oil,1725920,242679
AU,Oil,2178870,543554
BE,Oil,1024675,60304
;
run;I expect to create three X Y scatter for each INDUSTRY
I would like to put the value of "R&D" at Y-axis and value of "Patent" at X-axis and the value of "
INDUSTRY" as the title of each scatter. SO the value of each country is expected to be displayed as a point on each scatter chart.
Could you please give me some suggestion about this?
thanks in advance.
For three plots in one image, you will want to use Proc SGPANEL.
Proper data is important, the sample in your question does not input properly. The sample code below fixes the input:
data have; attrib country_code length=$2 industry length=$20 label = "INDUSTRY" rnd format=dollar12. label = 'R & D' patents format=dollar12. label = 'Patent' ; INFILE CARDS DSD DLM=','; input country_code industry rnd patents; datalines; AT,Manufacture,4316550,2033058 AU,Manufacture,2701929,961452 BE,Manufacture,1935804,564041 AT,Service,2069617,483619 AU,Service,1058213,235353 BE,Service,1024675,60304 AT,Oil,1725920,242679 AU,Oil,2178870,543554 BE,Oil,1024675,60304 ; proc sgpanel data=have; panelby industry / columns=1; scatter x=patents y=rnd / datalabel=country_code; run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.