# Problem with plotting with SAS

I'm very new to SAS, so please keep that in mind with any responses.

I've been running the following code in SAS:

FILENAME fishfile URL
"http://www.amstat.org/publications/jse/datasets/fishcatch.dat";
PROC FORMAT;
VALUE sexfmt 0="female" 1="male";
VALUE speciesfmt 1="common bream" 2="whitefish" 3="roach"
4="silver bream" 5="smelt" 6="pike" 7="perch";
INVALUE misscode "NA"=. ;
RUN;
DATA fish;
INFILE fishfile;
INPUT obs species weight length1 length2
length3 hgtpct widpct sex;
INFORMAT weight sex misscode.;
LABEL length1="Nose to tail beginning length"
length2="Nose to tail notch length"
length3="Nose to tail end length";
FORMAT species speciesfmt. sex sexfmt.;
RUN;


All of the above code runs without any errors. The following code gives me errors:

TITLE "Finnish Fish: Species distribution";
PROC SGPLOT DATA=fish;
VBAR species;
RUN;
TITLE "Finnish Fish: Weight in grams";
PROC SGPLOT DATA=fish;
HISTOGRAM weight;
RUN;


I can't access the data right now so I don't have the specific error, but it says something along the lines of "Insufficient authorization" when I try to view the resulting plots. I will post the actual error message when I can access the data again, but until then I'm hoping that someone has encountered this error and found a solution.

-

Are you trying to open the file directly in SAS? This has caused problems for me before when working on a server. However if I open up explorer and browse to where the png file is stored (probably where your SAS program is saved) you should be able to open it from there with a variety of programs. From there I think you can isolate the program that is giving you trouble.

-

I actually figured out the issue. I'm not listed as an Administrator on my school-issued laptop. As such, I cannot save to the Program Files folder. I changed the current directory for SAS and now I can access all of my plots and other output. Thanks for all of the responses, though!

-
I'd suggest accepting your own answer, as you've clearly solved your problem. I'm rather pleased that my guess - "This is probably a file permissions problem on your PC, rather than SAS itself", seems correct. –  EpiGrad Aug 31 '11 at 3:41
@EpiGrad - It took me a few error messages to actually realize what they were telling me. Next time, I will give myself a bit more time to understand the error before coming to SE. –  Max Aug 31 '11 at 12:08
Believe me, its a problem I'm well familiar with. Took me an embarrassingly long time once to figure out all the errors of an analysis were coming from me failing to use the right pathname for a file. At least it wasn't a semi-colon. –  EpiGrad Aug 31 '11 at 21:51

I've solved this problem in the past by ensuring that either my SAS working directory is set to a disk I know I can write to (especially if SAS is running on an application server like Citrix) or by submitting

ODS LISTING GPATH = "C:\Documents";

For example, assuming that you can access the C:\Documents folder.

-

Which version of SAS are you running?

In v. 9.3 (the latest) this ought to open a HTML window right in your session. In 9.2, you would need "ods graphics on" before the code and "ods graphics off" afterward. However, in either version you can save the output by, e.g.

ods rtf file = "c:\myfile.rtf";


before the code and

ods rtf close;


after the code. There are other formatting options as well, including png and html and other formats.

-
You never need "ods graphics on" before an SGPLOT call. Only before statistical procs. –  Rick Wicklin Sep 2 '11 at 19:09