Data visualization with SAS programming

Import in Adobe Illustrator .svg file from SGRENDER

Accepted Solution Solved
Reply
Super Contributor
Posts: 543
Accepted Solution

Import in Adobe Illustrator .svg file from SGRENDER

Greetings!

I am currently dealing with a graphics problem between SAS and Adobe Illustrator.

I need to create a report (large report) that contains hundreds of graphics.

The decision has been made that we (the analysts) should create .svg graphics that can be brought into Adobe Illustrator (by some editor person).

Thus far, we managed to successfully create editable .svg graphics in Adobe Illustrator from PROC GMAP, PROC GCHART.

We have not been able to create any graphics via any of the PROC SG, including GTL + SGRENDER.

Again, we would like to use SAS to create a .svg graphic, then import that .svg in Adobe Illustrator and be able to edit it.

We don't want to use the SGEditor.

We most likely want to have the ability to move legends and such as depending on a given page text.

Here is code that produces editable svg in Adobe illustrator and code that doesn't.

*--------------GMAP;

goptions reset=goptions device=svg;

ods printer file='M:\SVG_LOOKING_PLOT_W_GMAP.svg' ;

ods listing close;

proc gmap data=maps.us map=maps.us ;

   id state;

   choro state / levels=1 statistic = mean;

run;

quit;

ods printer close;

ods listing; 

title;

/*--Data Set SeriesGroup--*/

data SeriesGroup;

  drop i;

  length Class $6;

  format Date monname3.;

  do i=0 to 334 by 10;

    date='01jan2009'd+i;

    Drug='A'; Value = 16+ 3*sin(i/90+0.5) + 1*sin(3*i/90+0.7); Class='NSAID'; Company='XX'; output;

    Drug='B'; Value = 10+ 3*sin(i/90+0.5) + 1*cos(3*i/90+0.7); Class='NSAID'; Company='XX'; output;

    Drug='C'; Value = 10+ 3*cos(i/90+0.5) + 1*sin(3*i/90+0.7); Class='Opioid'; Company='YY'; output;

    Drug='D'; Value = 20+ 3*cos(i/90+0.5) + 2*sin(3*i/90+0.7); Class='Opioid'; Company='YY'; output;

  end;

run;

proc sort data=SeriesGroup out=SeriesGroupSorted;

  by drug;

  run;

/*--Create drug label for each curve at every 5th value--*/

data SeriesGroupLabel;

  set SeriesGroupSorted;

  if mod(_n_, 5) = 1 then do;

    Label=Drug;

    ValueL=Value;

  end;

  run;

/*--Standard Series Plot--*/

proc template;

  define statgraph Series;

    begingraph / ;

      entrytitle 'Values by Date and Treatment';

      layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data));

        seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true;

        discretelegend 'a' / title='Drug:';

      endlayout;

    endgraph;

  end;

run;

goptions reset=goptions device=svg;

ods printer file='M:\series_plot.svg' ;

ods listing close;

/*--Standard Series Plot--*/

ods graphics / reset width=5in height=3in imagename='Series_Plot';

proc sgrender data=SeriesGroup template=Series;

run;

ods printer close;

ods listing; 

title;

Any advice would be highly appreciated!!

Thank you in advance.

Sincerely,

Anca.

NDER


Accepted Solutions
Solution
‎06-13-2014 07:13 AM
Super Contributor
Posts: 273

Re: Import in Adobe Illustrator .svg file from SGRENDER

In 9.3,  i have observed the same difficulty

AI  seems not to recognize  svg  files actually   following our editorial  team.

The by pass that is working well and produces vectorial files is EMF

and tested with AI

Andre

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,081

Re: Import in Adobe Illustrator .svg file from SGRENDER

With SAS 9.4, you can set OUTPUTFMT=SVG on the ODS GRAPHICS stmt.  ODS Graphics does not look at GOPTION.

Yes, it works in SAS 9.3, but SUBPIXEL=ON (SAS 9.4) will make a much nicer quality graph.  Run in Chrome to see the graph.

/*--Standard Series Plot--*/
proc template;
  define statgraph Series;
    begingraph / subpixel=on;
      entrytitle 'Values by Date and Treatment';
      layout overlay / xaxisopts=(display=(ticks tickvalues) timeopts=(tickvalueformat=data));
        seriesplot x=date y=value / group=drug name='a' lineattrs=(thickness=2) smoothconnect=true;
        discretelegend 'a' / title='Drug:';
      endlayout;
    endgraph;
  end;
run;

/*--Standard Series Plot--*/
ods html;
ods graphics / reset width=5in height=3in outputfmt=svg imagename='Series_Plot';
proc sgrender data=SeriesGroup template=Series;
run;
ods printer close;
ods listing; 
title;

Attachment
Super Contributor
Posts: 543

Re: Import in Adobe Illustrator .svg file from SGRENDER

Thank you, Mr. Sanjay.

I can see the graph in Chrome.

It is Adobe Illustrator that does not open the graph, and this is what I need to use for  this specific report.

Are there any additional options or statements I need to use to make that 'link' between a SAS .svg created plot to Adobe Illustrator,,,,

Thank you!!

Anca.

Solution
‎06-13-2014 07:13 AM
Super Contributor
Posts: 273

Re: Import in Adobe Illustrator .svg file from SGRENDER

In 9.3,  i have observed the same difficulty

AI  seems not to recognize  svg  files actually   following our editorial  team.

The by pass that is working well and produces vectorial files is EMF

and tested with AI

Andre

SAS Super FREQ
Posts: 1,081

Re: Import in Adobe Illustrator .svg file from SGRENDER

The Adobe Illustrator documentation suggests that it can import PDF files.  Have you tried importing the PDF output into Illustrator?

Super Contributor
Posts: 543

Re: Import in Adobe Illustrator .svg file from SGRENDER

I figure out the EMF code. and it creates the editable graphics. So does the .PS files...!

Thank you!

proc template;

  define statgraph ClusterBar;

       begingraph / designheight=600px designwidth=1000px ;

         layout overlay /cycleattrs=true

                        walldisplay=none

                        yaxisopts=(griddisplay=on display=(tickvalues label))

                        xaxisopts=(display=(label line tickvalues));

            barchart x=sex y=age /outlineattrs=(color=white) group=group groupdisplay=cluster name="legname";

            discretelegend "legname" /location=inside across=1 OPAQUE=TRUE BORDER=FALSE ;

          endlayout;

  endgraph;

  end;

run;

options nodate nonumber printerpath=(emf grafout);

ods _all_ close;

ods graphics/outputfmt = emf;

ods printer printer=emf file="m:\sample_emf.emf" style=minimal;

proc sgrender data=sashelp.class template=ClusterBar objectlabel="sample_emf";

    DYNAMIC xvar="fi" yvar="pct_row" group="sex"

            legname="NW" halign="left" valign="top";

run;

ods printer close;

ods results;

Anca.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 893 views
  • 6 likes
  • 3 in conversation