sas >> what system options can you use to debug a SAS program

by jayakumarreddy » Wed, 16 Apr 2008 01:47:12 GMT

what system options can you use to debug a SAS program?
debugging here is debugging in sas datastep, sas proc and sas macros.

sas >> what system options can you use to debug a SAS program

by RolandRB » Wed, 16 Apr 2008 03:33:41 GMT


On Apr 15, 7:47m, XXXX@XXXXX.COM (Jayakumar Ramachandra)


One of the things I HAVE to do from time to time, with my macros, is
to cut and paste the code into the advanced editor and just run it. It
often picks up errors I have not seen and can save me many hours of
debugging.

sas >> what system options can you use to debug a SAS program

by gerhard.hellriegel » Wed, 16 Apr 2008 16:01:34 GMT

You should not do all in one step. First level should be the macro. To be
sure that the macro produces what you want, use the MPRINT (or MACROGEN)
option. With that you see what the macro produces (or not).
Second thing, if you assume that the right code is produces, but the
contents of macro variables are not that what you expect, use SYMBOLGEN.
If that is ok, the logic might be not ok: MLOGIC. Do NOT use all that
options together! Your log is full and you won't find what you're looking
for.
There are some others, look in the docu for that.

Second is a data-step and 7 or procs.
Options source source2 (to see includes) notes. Some others like MSGLEVEL
for example, all are for more or less informations in the log.

For the datastep there is a real debugger available:

data test / debug;


you can then step through the code, watch variable contents and follow the
logic of the program flow. That might be the last thing, if pure thinking
and code review does not help.

Gerhard



On Tue, 15 Apr 2008 13:47:12 -0400, Jayakumar Ramachandra

sas >> what system options can you use to debug a SAS program

by RolandRB » Wed, 16 Apr 2008 18:29:49 GMT

On Apr 16, 10:01m, XXXX@XXXXX.COM (Gerhard


MACROGEN is out of date now. You won't find it in the sas
documentation. They expect you to use MPRINT instead.

sas >> what system options can you use to debug a SAS program

by chris » Wed, 16 Apr 2008 18:59:08 GMT

Hi Jayakumar,

I wrote my 'Elvis' program to help with debugging large SAS macros -
it's a log analyser that makes browsing SAS logs much easier,
particularly if you're working with a typical batch system. Give it a
try!

Chris.
--------------------------------------------------------
Elvis SAS Log Analyser - http://www.oview.co.uk/elvis
Version 1.4 now available - try the new Date Calculator!
--------------------------------------------------------

On 15 Apr, 18:47, XXXX@XXXXX.COM (Jayakumar Ramachandra)

sas >> what system options can you use to debug a SAS program

by gerhard.hellriegel » Wed, 16 Apr 2008 23:11:54 GMT

... it's a secret option! It still works but does the same thing as MPRINT.


On Wed, 16 Apr 2008 03:29:49 -0700, RolandRB < XXXX@XXXXX.COM >



be
looking
MSGLEVEL
the
thinking

Hide quoted text -

sas >> what system options can you use to debug a SAS program

by datanull » Wed, 16 Apr 2008 23:48:24 GMT

earching at support.sas.com I got 19 hits for macrogen. Most of them
are graphics program examples with the following line.

options mprint macrogen symbolgen;

One use note suggested that MACROGEN may cause a memory error, and
suggested using MPRINT.

The following example indicates that the options do produce similar results.

64 %macro main;
65 title "&sysdate";
66 %PUT NOTE: %sysfunc(getoption(macrogen,keyword))
%sysfunc(getoption(mprint,keyword));
67 proc print data=sashelp.class;
68 run;
69 %mend;
70 options nomprint nomacrogen;
71 %main;
NOTE: NOMACROGEN NOMPRINT

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


72 options macrogen;
73 %main;
MACROGEN(MAIN): title "16APR08";
NOTE: MACROGEN NOMPRINT
MACROGEN(MAIN): proc print data=sashelp.class;
MACROGEN(MAIN): run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


74 options nomacrogen mprint;
75 %main;
MPRINT(MAIN): title "16APR08";
NOTE: NOMACROGEN MPRINT
MPRINT(MAIN): proc print data=sashelp.class;
MPRINT(MAIN): run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


76 options mprint macrogen;
77 %main;
MPRINT(MAIN): title "16APR08";
NOTE: MACROGEN MPRINT
MPRINT(MAIN): proc print data=sashelp.class;
MPRINT(MAIN): run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


78 options nomprint nomacrogen;





On Wed, Apr 16, 2008 at 10:11 AM, Gerhard Hellriegel
< XXXX@XXXXX.COM > wrote:

sas >> what system options can you use to debug a SAS program

by iw1junk » Thu, 17 Apr 2008 05:31:48 GMT

Gerhard wrote

... it's a secret option! It still works but does the same thing as
MPRINT.

Not quite. MACROGEN may write SAS code generated in the 1984 macro
language, but it is actually much older. Here is a "legitimate" use
of MACROGEN

114 data _null_ ; x = xxx ; put x= ; run ;

x=1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


115 options macrogen ;
116 data _null_ ; x = xxx ; put x= ; run ;
NOTE: The old-style macro XXX is beginning resolution.
117 + 1
NOTE: The old-style macro XXX is ending resolution.

x=1
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds

I intentionally haven't shown the code for the macro. If you don't
know it, you shouldn't play with it. It was probably a bad idea to
add MPRINT abilities to MACROGEN in the first place.

Ian Whitlock

sas >> what system options can you use to debug a SAS program

by datanull » Thu, 17 Apr 2008 05:46:47 GMT


What's the harm? Does this look a little bit like %let? Back in the
day, named them beginning with an underscore to help me identify them
more easily.

macro xxx 1%

I reckon we could say the same thing about the "modern" macro
language. Or just look for regular SAS language solution. You will
be much happier at the end of the day.

sas >> what system options can you use to debug a SAS program

by chang_y_chung » Thu, 17 Apr 2008 07:50:53 GMT


hi, data _null_,
well... at least one person wondered if the old-style macros are "dust
bunnies from hell" or not:
see http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0406B&L=sas-l&D=0&P=17981
or http://tinyurl.com/5cgtx2 :-)
cheers,
chang

sas >> what system options can you use to debug a SAS program

by iw1junk » Sat, 19 Apr 2008 05:15:51 GMT

Data_null,

The only harm is that they are terribly inefficient. One might be tempted to use
them instead of the better %LET, and I don't think it is wise to mix the systems.
At one time I did find a problem with mixing the languages, but I don't remember
the example. My point was simply that MACROGEN was an option that
belonged to a different macro system and that was probably an unwise
decision to expand it to show code that MPRINT shows.

Prefixing the names with an underscore is a fine idea for the programmer, but it
isn't system recognized, so the token handler still has to check every SAS name
token against a table of old macro names once there is an old style macro defined.

Ian Whitlock

-------------- Original message ----------------------
From: "data _null_," < XXXX@XXXXX.COM >

Similar Threads

1. book review: Debugging SAS Programs

2. Debug SAS programs with SEG

Hi all

Is it possible to debug a SAS program in SEG, like the option /debug
in SAS ?
I have SEG 2.1 on Windows and SAS 9.1.3 on UNIX.

Thanks

Christophe Paratte
www.paratte.net

3. How to debug a SAS program?

4. DEBUGGING PROGRAM

>  %do i=1 %to 4;
>  var&i.=itm(&i.);

this resolves to:
var4=itm(4);

whereas the dimension of your array is hardcoded as 3

> %a(array=%str(array itm(3) sbp_bc sbp_be sbp_bx ),ord=1);

Ron Fehd  the array
           or macro maven  CDC Atlanta GA USA RJF2 at cdc dot gov

> -----Original Message-----
> From: Rathindronath

> I have a part of a program as follows:
>
> %macro a(array=,ord=);
>  %do i=1 %to 4;
>   data g&i.(keep=patid var&i.) ;
>     &array.;
>     set part&ord.;
>  var&i.=itm(&i.);
>   run;
>
>   proc summary data=g&i. nway;
>     var var&i.;
>   output out=mn&i.(drop=_type_ _freq_) n=n mean=mean std=std
> median=med
> min=min max=max;
>   run;
>
>   proc transpose data=mn&i. out=tmn&i.(rename=(col1=col&i.));
>   run;
>
>   data tmn&i.;
>     set tmn&i.;
>  if upcase(_name_)='N' then order=1;
>  else if upcase(_name_)='MEAN' then order=2;
>  else if upcase(_name_)='STD' then order=3;
>  else if upcase(_name_)='MED' then order=4;
>  else if upcase(_name_)='MIN' then order=5;
>  else if upcase(_name_)='MAX' then order=6;
>   run;
>
>   proc sort data=tmn&i.;
>     by order;
>   run;
> %end;
>
>  data all&ord.;
>    merge %do i=1 %to 4;
>            tmn&i.
>    %end;;
>    by order;
>    item=&ord.;
>  run;
>
> %mend;
> %a(array=%str(array itm(3) sbp_bc sbp_be sbp_bx ),ord=1);
> %a(array=%str(array itm(3) dbp_bc dbp_be dbp_bx ),ord=2);
> %a(array=%str(array itm(3) hrt_bc hrt_be hrt_bx ),ord=3);
> %a(array=%str(array itm(3) temp_bc temp_be temp_bx ),ord=4);
>
>
>
> I HAVE THE FOLLOWING ERROR FOR EACH MACRO:
>
>
> ERROR: Array subscript out of range at line 13 column 78.
> sbp_bc=124 sbp_be=111 sbp_bx=112 PATID=10001 SITE=10 var4=
> _ERROR_=1 _N_=1
> NOTE: The SAS System stopped processing this step because of errors.
> NOTE: There were 1 observations read from the data set WORK.PART1.
> WARNING: The data set WORK.G4 may be incomplete.  When this step was
> stopped there were 0 observations and 2 variables.
> NOTE: DATA statement used:
>       real time           0.01 seconds
>       cpu time            0.01 seconds
>
>
> HOW CAN I FIX THE ERROR? THANKS EVERYONE
>
>

5. Course***An Introduction to SAS System and Programming

6. Emailing SAS Graphs using the pull down option -- SAS 9.1

I think this is what I would expect.  There is no love lost between the
space on my hard drive and BMP files.  I find them to be extremely
inefficient and prefer one of the compressed formats, selecting the level of
compression the task will bear.  This also means I specify an output file
name and use an appropriate SAS/Graph driver for the output.

The default behaviour is useful only to demonstrate that the graph
generation works and that the email engine is correctly configured.
Depending on an approach that delivers bloat mails puts my work at risk of
not being read due to file sizes and email filtering rules.  So in answer to
question 1; no.

Which means that my answer to question 2 is also no.

You should bear in mind though that I don't consider my work to be part of
the "average" community, especially when so many people are performing D & M
stat  analyses, and a lot of others produce ad-hoc and one-off analysis and
reporting.

Good luck in solving your issue.

Kind regards

David


-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ]On Behalf Of Nat
Wooding
Sent: Wednesday, 15 August 2007 12:32 AM
To:  XXXX@XXXXX.COM 
Subject: Emailing SAS Graphs using the pull down option -- SAS 9.1 under
Windows


Version:  9.1, TS1M3 under Win XP Pro

If one creates a graph using SAS Graph and then clicks on File/Send Mail. a
new message will be created in one's email system and the graph will appear
as an
attached BMP file. This is a nice feature since the alternative would be to
export the file, go to email, open a new message, and attach the file.

However -- and this is my main gripe -- there appears to be no option for
naming the attached file. A second gripe is that one can only add one graph
using this feature.

Question1: Does anyone else use this method of emailing a graph

Question2: Are you, too, bugged by this limitation in naming the
attachment.

I have opened a track with tech support (US 6611975) but I thought that I
would poll the group and see what the SAS community feelings are.

Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977


-----------------------------------------
CONFIDENTIALITY NOTICE:  This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect.  The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized.  If you are not the intended
recipient, any disclosure,  copying, distribution, or use of the
contents of this information is prohibited and may be unlawful.  If
you have received this electronic  transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it.  Thank you.

7. Is there any command/option for getting total time of a SAS program

8. USING 'DBLIBINIT' SAS Libname Option for SAS Access for Oracle

Hi all,

We are trying to use this option to pass user context information to
the database for Fine Grain Access Control.

We were able to pass a simple insert statement through this method that
inserts a number in table as:

DBLIBINIT='Insert into Y values (3)'

This works also:
DBLIBINIT='BEGIN epi.ins_num(3); END;'


We were not able to pass an insert that uses a character value like:

DBLIBINIT='Insert into Y values ('A')'
DBLIBINIT='BEGIN epi.ins_char('A'); END;'

It doesn't seem to matter how we quote the value.

Our actual requirement is to pass this:

DBLIBINIT= 'BEGIN epi.epi_clearance ('STD','20083','SE'); END;'

Can somebody explain what the solution is for this?