SAS Certification program problem

Reply
Occasional Contributor
Posts: 15

SAS Certification program problem

I would like to run the program referenced in the SAS Certification Guide for Base SAS, p. X.  I can't follow the instructions, because the book was designed for regular SAS, and I am using SAS Studio.  I found the actual program at http://support.sas.com/publishing/cert/sampdata.txt.  To test it out, I copied the first 93 lines of the code, through the proc print data=work.reliable step, into the SAS studio program window.  (I added the missing quotation mark after 'SMYTHE.') When I ran the code, I got no notes in the log, and no output.  I probably need to edit the program to make it compatible with SAS Studio.  Can anyone help? Thanks.

Super Contributor
Posts: 644

Re: SAS Certification program problem

I ran the code in SAS University edition on a Mac from line 9 (excluding the heading) to line 109 with the following result in the log

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42         ;

43         options nosource nonotes nocardimage validvarname=V7 replace;

150        ;

Line 1 is inserted by the Uni Ed.  The next options statement turned of source (the echo of program statements) and notes so there is nothing to tell you that 2 datasteps ran sucessfully.  Neither of them produce results in the outputs pane.  The first datastep creates a number of filenames for source data to be populated in subsequent steps, and the second creates a sas program called accnt03.sas, which you should find saved somewhere.  The proc print is part of this other program, which does not run at this stage so there is no print output.

Try running that part of the program again with the notes option on: you should see in the log

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

42         ;

43         options nosource notes nocardimage validvarname=V7 replace;

NOTE: DATA statement used (Total process time):

       real time           0.14 seconds

       cpu time            0.19 seconds

      

NOTE: The file ACCNT03 is:

       Filename=/folders/myfolders/sasuser.v94/accnt03.sas,

       Owner Name=sasdemo,Group Name=sas,

       Access Permission=-rw-rw-r--,

       Last Modified=06Sep2014:09:44:08

NOTE: 7 records were written to the file ACCNT03.

       The minimum record length was 4.

       The maximum record length was 37.

NOTE: DATA statement used (Total process time):

       real time           0.04 seconds

       cpu time            0.05 seconds

 

You fixed one error in the code for accnt03.sas, but there are several others and I suspect the errors there are deliberate, as part of the course, so don't expect running that program to produce print output.


I encountered several other problems running the code, which you may also need to address.

  1. The SAS Uni version write protects the sasuser library, so all the datasteps that attempt to create tables there fail.  I got round this by creating a folder and library called example, and changing all instances of "sasuser." to "example.".
  2. The first datastep creates a number of filenames but some of them are longer than 8 characters so attempted writes to those references failed.  I changed all references of "creditcardcomma" to "credcrdc" and "creditcard" to "credcrd", also "phonesurvey" to "phonsurv".
  3. There is a non space character in this data line between LAP and 02 for data work.reps which needs to be deleted and replaced with a space

JFL LAP02 1600.00 150.00

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Richard,

  Thank you for your reply.  I changed options nonotes nosource to options notes source.  I have some follow-up questions:

When I run all the code (through line 109), the lines

data work.balnew1;

set sasuser.insure;

run;

proc print data=work.balnew1;

var id name total balancedue;

do not appear in the log, and there is no note about them.  Why is that?

When I try to run just these lines (I added a run statement here), I get the message

ERROR: File SASUSER.INSURE.DATA does not exist.

Why do I get an error message for just these lines, and I don't get an error message when I run the whole program?

Also, you explained that I can't write to SASUSER, but why can't I access a dataset from SASUSER?

Thanks.

                 Roberta

Super User
Super User
Posts: 6,317

Re: SAS Certification program problem

It can read from the SASUSER library, but it is saying the there is no such dataset in SASUSER library. 

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Thanks!

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Richard,

  In your reply, you have the following from the log:

NOTE: 7 records were written to the file ACCNT03.

       The minimum record length was 4.

       The maximum record length was 37.

However, when I run the program, I get the following:

NOTE: 4 records were written to the file ACCNT03.

  The minimum record length was 4.

  The maximum record length was 28.

Why the discrepency?

Thanks.

                    Roberta

Super Contributor
Posts: 644

Re: SAS Certification program problem

Roberta

I suspect you are learning as much from trying to implement this code as you will from the course.  Continue to ask questions about things that are unclear.

I take it your questions on SASUSER are now answered though.

In the following code the first 7 lines down to datalines4; are the "program" part.  The remaining lines (in italics) down to the run before the ;;;; are data in this context, even though they look like subsequent program statements.  This piece of code is reading the data lines and then filing (saving) them to the file acct03.  Subsequently, as part of the course, you are intended to use acct03 as a program and I imagine identify all the errors in it.

By my count there are 7 lines to be read as data and written to acct03 so I am unable to say why you only read 4, except to say your read ended after the first run statement in the data, leaving out the proc print.

data _null_;

        infile cards4 missover length=l;

        length text $ 50;

        input text $varying50. l;

        file accnt03;

        put text;

datalines4;

data work.reliable;

set clini.insure;

where company='FRED SMYTHE;

run;

proc print data=work.reliable

var id name company total balancedue;

run;

;;;;

run;

Richard

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Thanks, everyone, for your help.  I finally got connected with Cynthia Zender from SAS. She sent me some new code that can be run on SAS Studio.  I ran the code (after changing "sasuser" to "cert"), and it ran the first time!

                                          Roberta

Super User
Super User
Posts: 6,317

Re: SAS Certification program problem

The biggest problem that I see when looking at the code is that wants to write to the SASUSER library.

You cannot do that in SAS University Edition and personally I would never do that in regular SAS because if you try to run multiple SAS sessions at the same time your SASUSER library is not writable.  In fact I normally run SAS with the -RSASUSER option (just like the setting in SAS University Edition).  This prevents SAS from losing your window locations and key definition when you open a second session.

Try changing all SASUSER to WORK and the program will probably work.

Super User
Super User
Posts: 6,317

Re: SAS Certification program problem

There is also a logic error in that program. It has a data step at the top that uses the FILENAME() function to assign filerefs for a series of physical files that it wants to create.

But some of the names, like phonesurvey are longer than 8 characters.  So in step that issues the FILENAME() function call these names are truncated to 8 characters. But then later on there is a data step where it is writing those files using another DATA step it references the full name.  This causes SAS to not use the fileref (since they do not match) and instead try to write the file in the current working directory, but that directory is read only on the locked down virtual machine that is running SAS.

If you eliminate the options statement at the top of the program that is setting NONOTES and NOSOURCE then you can see the error messages in the log and tell which steps need to be fixed.

There are three files that have this problem.

ERROR: Change reference to creditcard

ERROR: Change reference to creditcardcomma

ERROR: Change reference to phonesurvey

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Thanks!

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Tom,

  Thanks!

         Roberta

SAS Super FREQ
Posts: 8,717

Re: SAS Certification program problem

Hi, Roberta:

     

  The short answer to your question is that yes, you can continue to use SAS Studio and the SAS University Edition with the Certification Prep Guide. However, the SAS University Edition did not exist at the time the original program for the Prep Guides was written, so the program is currently designed to work on a machine where the student has write access to the SASUSER library. But, this is not the case with the University Edition -- in the University Edition, the SASUSER library is a read-only library. This presents an issue if you try to run the program used for the Prep Guides, as it was originally written. This is the reason that the current program, as written will generate error messages if you run it in the SAS University Edition.

       
  We are in the process of publishing the revised program so that it will work with the SAS University Edition and other operating systems, as well. But while that updated program has been tested in the field, it has not been pushed to the publishing site for the book yet. If you send mail to training@sas.com, then you can request that we send you the updated program for working with the Base Programmer and Advanced Programmer Prep Guides.

  

  In short, the fix is that it is possible to "redirect" your SASUSER library to a location in the SAS Studio interface to the University Edition, where you do have write access (such as your shared folder. The other thing is that in testing the program, we discovered a few other pieces of the syntax that needed to change, So you need to get the updated program AND redirect your SASUSER library.

  cynthia

Occasional Contributor
Posts: 15

Re: SAS Certification program problem

Cynthia,

  Thank you very much!

               Roberta

Ask a Question
Discussion stats
  • 13 replies
  • 1514 views
  • 4 likes
  • 4 in conversation