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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Andre
Obsidian | Level 7

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

5 REPLIES 5
Jay54
Meteorite | Level 14

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;

AncaTilea
Pyrite | Level 9

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.

Andre
Obsidian | Level 7

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

Jay54
Meteorite | Level 14

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

AncaTilea
Pyrite | Level 9

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.

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!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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