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

I am running macro gernerating PLOTS from PROC SGPLOT, and need 

save the plots out with explicit filename/location.

 

How ? Any Help?

 

The code below seems generated the file somewhere. But I cannot find anywhere.

If put dir path, it complains. 


25813  %let plotvar=vol_dif_wt_csum;
25814  title "var=&plotvar.";
25815      ods layout gridded columns=2 rows=2 advance=table;
25816      ods graphics /width=600px height=400px   imagename="_TEST_"  outputfmt=png ;
25817      proc sgplot data=_index_avg_cmp_f_4grp(where=( ind between &endind. -1000 and
25817! &endind.+100));
25818              by  blw_flag abv_flag;
25819              series x=ind y=&plotvar. /  lineattrs=( color=blue thickness=2 pattern=solid);
25820              series x=ind y=&indexout._orig / y2axis   lineattrs=( color=red thickness=2
25820! pattern=solid);
25821              refline  &endind./axis=x lineattrs=(color=blue thickness=2 pattern=solid);
25822              refline  &refind./axis=x lineattrs=(color=lime thickness=1 pattern=solid);
25823      run;

25823!         quit;
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.76 seconds
      cpu time            0.14 seconds

NOTE: There were 1972 observations read from the data set WORK._INDEX_AVG_CMP_F_4GRP.
      WHERE (ind>=6100 and ind<=7200);

25824      ods layout end;
25825  %let plotvar=vol_dif_wt_csum;
25826  title "var=&plotvar.";
25827      ods layout gridded columns=2 rows=2 advance=table;
25828      ods graphics /width=600px height=400px   imagename="D:\_TEST_"  outputfmt=png ;
WARNING: The IMAGENAME option or the output name contains invalid characters. D___TEST_ will be used
         as the image name prefix.
25829      proc sgplot data=_index_avg_cmp_f_4grp(where=( ind between &endind. -1000 and
25829! &endind.+100));
25830              by  blw_flag abv_flag;
25831              series x=ind y=&plotvar. /  lineattrs=( color=blue thickness=2 pattern=solid);
25832              series x=ind y=&indexout._orig / y2axis   lineattrs=( color=red thickness=2
25832! pattern=solid);
25833              refline  &endind./axis=x lineattrs=(color=blue thickness=2 pattern=solid);
25834              refline  &refind./axis=x lineattrs=(color=lime thickness=1 pattern=solid);
25835      run;

25835!         quit;
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.44 seconds
      cpu time            0.09 seconds

NOTE: There were 1972 observations read from the data set WORK._INDEX_AVG_CMP_F_4GRP.
      WHERE (ind>=6100 and ind<=7200);

25836      ods layout end;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

😓 This ?

data _temp;
do grp1=1 to 3;
	do grp2=1 to 3;
		do ind=1 to 100;
			y=grp1*10+grp2+sin(ind/10); output;
		end;
	end;
end;
run;

title;
ods _all_ close;
options nodate nonumber ;
options leftmargin="0.001in" rightmargin="0.001in" topmargin=1cm;
options papersize=(10.00in 8.50in);

ods printer printer=png300 file="c:\temp\dashboard.png" style=normalprinter nogtitle; 

ods layout gridded columns=3 advance=bygroup column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=3.00in noborder ;
		proc sgplot data=_temp;
			by grp1 grp2;
			series x=ind y=y/  lineattrs=( color=red thickness=2 pattern=solid);  
	run;quit; 

ods layout end;
ods printer close;

Ksharp_0-1764322835219.png

 

View solution in original post

7 REPLIES 7
andreas_lds
Jade | Level 19

Hardly possible to suggest something useful without knowing the code of the macro.

The ods gpath option may be used to set the location images are stored, see https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatug/p0cmojsdkiab8cn1k2qk3rp3a8s0.htm for details.

Ksharp
Super User

Check this:

https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures...

 

ods _all_ close;
options nodate nonumber;
options leftmargin="0.001in" rightmargin="0.001in";
options papersize=(7.35in 3.00in);

title "Sales Dashboard";
ods printer printer=png300 file="dashboard.png" style=normalprinter;
hellohere
Pyrite | Level 9

Thanks.  But still have issue. 

 

The picture is saved out. But only one out of n-by-M.

data _temp;
do grp1=1 to 3;
	do grp2=1 to 3;
		do ind=1 to 100;
			y=grp1*10+grp2+sin(ind/10); output;
		end;
	end;
end;
run;quit;

ods _all_ close;
options nodate nonumber;
options leftmargin="0.001in" rightmargin="0.001in";
options papersize=(7.35in 3.00in);

ods printer printer=png300 file="dashboard.png" style=normalprinter; 
	proc sgplot data=_temp;
			by grp1 grp2;
			series x=ind y=y/  lineattrs=( color=red thickness=2 pattern=solid);  
	run;quit; 

Even just the code from the link. It does not show up right. 

 


data heart;
set sashelp.heart;
if (weight_status eq '') then weight_status="Unknown";
run;
proc sort data=heart; by weight_status; run;

ods printer printer=png300 file="bygroups.png" style=normalprinter;
ods layout gridded columns=2 rows=2 advance=bygroup
    column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=3.5in;
title "#byval1";
proc sgplot data=heart noautolegend uniform=xscale;
by weight_status;
yaxis offsetmin=0.05;
histogram cholesterol;
density cholesterol;
fringe cholesterol;
run;
ods layout end;
ods printer close;

 

bygroups.png 

Ksharp
Super User

😓 This ?

data _temp;
do grp1=1 to 3;
	do grp2=1 to 3;
		do ind=1 to 100;
			y=grp1*10+grp2+sin(ind/10); output;
		end;
	end;
end;
run;

title;
ods _all_ close;
options nodate nonumber ;
options leftmargin="0.001in" rightmargin="0.001in" topmargin=1cm;
options papersize=(10.00in 8.50in);

ods printer printer=png300 file="c:\temp\dashboard.png" style=normalprinter nogtitle; 

ods layout gridded columns=3 advance=bygroup column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=3.00in noborder ;
		proc sgplot data=_temp;
			by grp1 grp2;
			series x=ind y=y/  lineattrs=( color=red thickness=2 pattern=solid);  
	run;quit; 

ods layout end;
ods printer close;

Ksharp_0-1764322835219.png

 

hellohere
Pyrite | Level 9

How to set ODS to the default, BTW?!

 

Run the code below. It says "WARNING: No output destinations active." and no output in SAS. 

 

26305          proc sgplot data=_temp;
26306              by grp1 grp2;
26307              series x=ind y=y/  lineattrs=( color=red thickness=2 pattern=solid);
26308      run;

26308!         quit;
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.09 seconds
      cpu time            0.03 seconds

WARNING: No output destinations active.
NOTE: There were 900 observations read from the data set WORK._TEMP.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 193 views
  • 0 likes
  • 3 in conversation