57
Company Confidential - For Internal Use Only Copyright © 2013, SAS Institute Inc. All rights reserved. WHY DOES SAS ® SAY THAT? WHAT COMMON DATA STEP AND MACRO MESSAGES ARE TRYING TO TELL YOU CHARLEY MULLIN AND KEVIN RUSSELL SAS INSTITUTE INC., CARY, NC USA PRESENTED BY JAN SQUILLACE

What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Embed Size (px)

Citation preview

Page 1: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

WHY DOES SAS®

SAY THAT?

WHAT COMMON DATA STEP AND

MACRO MESSAGES ARE TRYING

TO TELL YOU

CHARLEY MULLIN AND KEVIN RUSSELL

SAS INSTITUTE INC., CARY, NC USA

PRESENTED BY JAN SQUILLACE

Page 2: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

TODAY YOU WILL LEARN TO…

•Better understand the SAS log

•Debug your code more easily

•Work more efficiently

Page 3: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

FIRST, LET’S DISCUSS THE DATA STEP

The benefits of DATA step:

• Gives you the ability to read external files

into SAS data sets

• Enables you to manipulate data into a more

usable form

• Enables you combine data from various

sources

• And more…

Page 4: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

IN THE SAS LOG, YOU WILL ENCOUNTER:

•Notes

•Warnings

•Errors

Page 5: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

APPLYING A NUMERIC FORMAT TO A

CHARACTER VARIABLE

Page 6: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

APPLYING A NUMERIC FORMAT TO A CHARACTER VARIABLE

Input var1 var2 var3 var4 $ var5 $;

Format var4 mmddyy8.;

2681 format var4 mmddyy8.;

--------

48

ERROR 48-59: The format $MMDDYY was not found

or could not be loaded.

Page 7: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

VARIABLES WITH MULTIPLE DEFINITIONS

Page 8: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

VARIABLES WITH MULTIPLE DEFINITIONS

ERROR: Variable VAR1 has been defined as both character and numeric.

data one;

input var1 $ var2;

datalines;

1 2

;

run;

data two;

input var1 var2;

datalines;

3 4

;

run;

data three;

merge one two;

by var1 var2;

run;

Page 9: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

VARIABLES WITH MULTIPLE DEFINITIONS (CONTINUED)

ERROR: Variable VAR1 has been defined as both character and numeric.

data one;

set one(rename=(var1=temp));

var1=input(temp,??8.);

drop temp;

run;

data two;

set two(rename=(var1=temp));

var1=put(temp,8.);

drop temp;

run;

Page 10: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INPUT TO CONCATENATION FUNCTIONS

Page 11: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INPUT TO CONCATENATION FUNCTIONS

NOTE: Argument 1 to function CATS at line N column X is invalid.

NOTE: Further warning from this call to CATS will be suppressed.

WARNING: In a call to the CATS function, the buffer allocated for the

result was not long enough to contain the concatenation of all

the arguments. The correct result would contain 1040

characters, but the actual result may either be truncated to

200 character(s) or be completely blank, depending on the

calling environment. The following note indicates the left-most

argument that caused truncation.

NOTE: Argument 1 to function CATS at line N column 6 is invalid.

Page 12: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INPUT TO CONCATENATION FUNCTIONS (CONTINUED)

data final;

merge group1(rename=(results=r1))

group2(rename=(results=r2))

group3(rename=(results=r3));

results=cats(r1,r2,r3);

run;

data final;

merge group1(rename=(results=r1))

group2(rename=(results=r2))

group3(rename=(results=r3));

length results $ 1040;

results=cats(r1,r2,r3);

run;

Page 13: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR

Page 14: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR

• NOTE: Invalid second argument to function

SUBSTR at line N column X.

• NOTE: Invalid third argument to function

SUBSTR at line N column X.

Page 15: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR (CONTINUED)

In typical usage, the three arguments to the

SUBSTR function are:

• The name of the variable from which to

extract characters

• The position in the variable to start

extracting characters

• The number of characters to extract

Page 16: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR (CONTINUED)

NOTE: Invalid second argument to function SUBSTR at line N column X.

data lab_work;

infile datalines truncover;

input raw $char20.;

machine=substr(strip(raw),1,4);

test_id=substr(strip(raw),6,4);

results=substr(strip(raw),11,4);

datalines;

1234 5678

1234 5678 9012

;

run;

Page 17: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR (CONTINUED)

NOTE: Invalid second argument to function SUBSTR at line N column

X.

data lab_work;

infile datalines truncover;

input raw $char20.;

machine=substr(left(raw),1,4);

test_id=substr(left(raw),6,4);

results=substr(left(raw),11,4);

datalines;

1234 5678

1234 5678 9012

;

run;

Page 18: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

ARGUMENTS TO THE FUNCTION SUBSTR (CONTINUED)

NOTE: Invalid third argument to function SUBSTR at line N column X.

data test;

date=‘24/04/2012’;

year=substr(date,7,10);

run;

data test;

date=‘24/04/2012’;

year=substr(date,7,4);

run;

Page 19: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOMATIC VARIABLE TYPE CONVERSIONS

Page 20: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOMATIC VARIABLE TYPE CONVERSIONS

• NOTE: Numeric values have been

converted to character values at the places

given by: (Line):(Column).

• NOTE: Character values have been

converted to numeric values at the places

given by: (Line):(Column).

Page 21: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOMATIC VARIABLE TYPE CONVERSIONS (CONTINUED)

NOTE: Numeric values have been converted to character values at the

places given by: (Line):(Column)

data test;

ssn=111223333;

first_three=substr(ssn,1,3);

run;

proc print data=test;

run;

The SAS System

first_

Obs ssn three

1 111223333

Page 22: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOMATIC VARIABLE TYPE CONVERSIONS (CONTINUED)

NOTE: Numeric values have been converted to character values at the

places given by: (Line):(Column)

data test;

ssn=111223333;

first_three=substr(put(ssn,z9.),1,3);

run;

proc print data=test;

run;

The SAS System

first_

Obs ssn three

1 111223333 111

Page 23: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

UNINITIALIZED VARIABLE

Page 24: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

UNINITIALIZED VARIABLE

NOTE: Variable FEMELE is uninitialized.

data two;

set one;

if sex=1 then gender=Femele;

run;

Page 25: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

UNINITIALIZED VARIABLE (CONTINUED)

SAS Log:

3652 data two;

3653 set one;

3654 if sex=1 then gender=Femele;

3655 run;

NOTE: Variable Femele is uninitialized.

Page 26: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

UNINITIALIZED VARIABLE (CONTINUED)

Correct syntax:

data two;

set one;

if sex=1 then gender=‘Female’;

run;

Page 27: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING A FUNCTION NAME AS AN ARRAY NAME

Page 28: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING A FUNCTION NAME AS AN ARRAY NAME

NOTE: The array <name> has the same

name as a SAS-supplied or user-defined

function. Parentheses following this name

are treated as array references and not

function references.

Page 29: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING A FUNCTION NAME AS AN ARRAY NAME (CONTINUED)

43 data test;

44 array max(3) max1-max3 (80 90 70);

NOTE: The array max has the same name as a SAS-supplied or

user-defined function. Parentheses following this name are

treated as array references and not function references.

45 max_value=max(of max(*));

ERROR: Too many array subscripts specified for array max.

46 run;

NOTE: The SAS System stopped processing this step because

of errors.

SAS log:

Page 30: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING A FUNCTION NAME AS AN ARRAY NAME (CONTINUED)

data test;

array max(3) max1-max3 (80 90 70);

max_value=max(of max(*));

run;

data test;

array maxx(3) max1-max3 (80 90 70);

max_value=max(of maxx(*));

run;

Page 31: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

THE MACRO FACILITY

Page 32: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

NOW LET’S DISCUSS THE MACRO FACILITY

The macro facility allows you to extend

and customize your code and reduce

the amount of text you must enter.

Page 33: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

WHEN USING THE MACRO FACILITY, USE THESE SYSTEM OPTIONS:

•SYMBOLGEN

•MPRINT

•MLOGIC

Page 34: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

MASKING SPECIAL CHARACTERS

Page 35: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

MASKING SPECIAL CHARACTERS

ERROR: Macro function %substr has too many arguments. The

excess arguments will be ignored.

%let x=a,b,c;

%let y=%substr(&x,1,1);

%put &=y;

%let x=a,b,c;

%let y=%substr(a,b,c,1,1);

%put &=y;

Page 36: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

MASKING SPECIAL CHARACTERS (CONTINUED)

Complete error in the SAS log:

189 %let x=a,b,c;

190 %let y=%substr(&x,1,1);

SYMBOLGEN: Macro variable X resolves to a,b,c

ERROR: Macro function %SUBSTR has too many arguments.

The excess arguments will be ignored.

ERROR: A character operand was found in the %EVAL function or

%IF condition where a numeric operand is required.

The condition was: b

ERROR: Argument 2 to macro function %SUBSTR is not a number.

ERROR: A character operand was found in the %EVAL function or

%IF condition where a numeric operand is required.

The condition was: c

ERROR: Argument 3 to macro function %SUBSTR is not a number.

191 %put &=y;

&=y

Page 37: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

MASKING SPECIAL CHARACTERS (CONTINUED)

Corrected code:

%let x=a,b,c;

%let y=%substr(%bquote(&x),1,1);

%put &=y;

This syntax is new for SAS 9.3

Page 38: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOCALL MACROS USED AS MACRO FUNCTIONS

Page 39: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOCALL MACROS USED AS MACRO FUNCTIONS

• %CMPRES and %QCMPRES

• %COMPSTOR

• %DATATYP

• %KVERIFY

• %LEFT and %QLEFT

• %LOWCASE and %QLOWCASE

• %TRIM and %QTRIM

• %VERIFY

Page 40: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOCALL MACROS USED AS MACRO FUNCTIONS (CONTINUED)

Example that illustrates a problem:

options mautosource sasautos=(‘c:\mymacs’);

%let x=%str(abc );

%let y=%trim(&x);

Page 41: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOCALL MACROS USED AS MACRO FUNCTIONS (CONTINUED)

SAS log:

3 options mautosource sasautos=('c:\mymacs');

4 %let x=%str(abc );

5 %let y=%trim(&x);

WARNING: Apparent invocation of macro TRIM not

resolved.

Page 42: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

AUTOCALL MACROS USED AS MACRO FUNCTIONS (CONTINUED)

Correct setting for the SASAUTOS system

option:

options mautosource sasautos=(sasautos, 'c:\mymacs');

%let x=%str(abc );

%let y=%trim(&x);

Page 43: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING MACRO VARIABLES IN FILENAMES

Page 44: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING MACRO VARIABLES IN FILENAMES

ERROR: Physical file does not exist, c:\class2011csv.

%let year=2011;

proc import

datafile="C:\class&year.csv"

dbms=csv

out=myclass

replace;

getnames=yes;

run;

Page 45: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING MACRO VARIABLES IN FILENAMES (CONTINUED)

ERROR: Physical file does not exist, c:\class2011csv.

datafile=“c:\class2011csv”;

Page 46: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

USING MACRO VARIABLES IN FILENAMES (CONTINUED)

ERROR: Physical file does not exist, c:\class2011csv.

Here is the correct syntax:

%let year=2011;

proc import datafile=“C:\class&year..csv”

dbms=csv

out=myclass

replace;

getnames=yes;

run;

Page 47: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REFERENCING STORED COMPILED MACROS

Page 48: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REFERENCING STORED COMPILED MACROS

ERROR: A LOCK IS NOT AVAILABLE FOR LIBREF.SASMACR.CATALOG.

Page 49: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REFERENCING STORED COMPILED MACROS (CONTINUED)

ERROR: A lock is not available for MYMACS.SASMACR.CATALOG.

libname mymacs ‘C:\macros’;

options mstored sasmstore=mymacs;

%macro test / store;

<code>;

%mend test;

%test

Page 50: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REFERENCING STORED COMPILED MACROS (CONTINUED)

SAS log:

NOTE: The SAS System was unable to open the

macro library referenced by the

SASMSTORE = libref MYMACS.

ERROR: A lock is not available for

MYMACS.SASMACR.CATALOG.

ERROR: A dummy macro will be compiled.

Page 51: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REFERENCING STORED COMPILED MACROS (CONTINUED)

Page 52: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INVOKING A MACRO WITH PARAMETERS

Page 53: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INVOKING A MACRO WITH PARAMETERS

Error: More positional parameters found than

defined.

%macro test(vals);

%put &=vals;

%mend test;

%test(x,y,z)

Page 54: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INVOKING A MACRO WITH PARAMETERS (CONTINUED)

SAS log:

19 %macro test(vals);

20 %put &=vals;

21 %mend test;

22 %test(x,y,z)

MLOGIC(TEST): Beginning execution.

MLOGIC(TEST): Parameter VALS has value x

ERROR: More positional parameters found than

defined.

MLOGIC(TEST): Ending execution.

Page 55: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

INVOKING A MACRO WITH PARAMETERS (CONTINUED)

Corrected code:

%macro test(vals);

%put &=vals;

%mend test;

%test(%str(x,y,z))

Page 56: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

REVIEW

• Variables with multiple definitions

• Concatenation function arguments

• Arguments to SUBSTR function

• Automatic variable type conversion

• Uninitialized variables

• Function name conflict with array name

• Macro debugging options SYMBOLGEN MPRINT MLOGIC

• Autocall macros used as macro functions

• SASAUTOS system option conflicts

• Macro variables used in filenames

• Stored compiled macros

• Macro parameters

Page 57: What Common DATA Step and Macro Messages are Trying … · what common data step and macro messages are trying to tell you charley mullin and kevin russell sas institute inc., cary,

Company Confidential - For Internal Use Only

Copyright © 2013, SAS Insti tute Inc. Al l r ights reserved.

Paper 248-2012

Why Does SAS® Say That? What Common DATA Step and Macro

Messages Are Trying to Tell You

Email: [email protected]

(919) 677-8008

http://support.sas.com/techsup

http://support.sas.com/resources