Squillace Erros
Squillace Erros
Squillace Erros
• Better
understand the SAS log
• Debug your code more easily
• Work more efficiently
• Notes
• Warnings
• Errors
ERROR: Variable VAR1 has been defined as both character and numeric.
data three;
merge one two;
by var1 var2;
run;
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;
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.
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;
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;
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;
data test;
date=‘24/04/2012’;
year=substr(date,7,10);
run;
data test;
date=‘24/04/2012’;
year=substr(date,7,4);
run;
1 111223333
data two;
set one;
if sex=1 then gender=Femele;
run;
SAS Log:
Correct syntax:
data two;
set one;
if sex=1 then gender=‘Female’;
run;
SAS log:
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(*));
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;
• SYMBOLGEN
• MPRINT
• MLOGIC
%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;
Corrected code:
%let x=a,b,c;
%let y=%substr(%bquote(&x),1,1);
%put &=y;
%let x=%str(abc );
%let y=%trim(&x);
SAS log:
%let year=2011;
proc import
datafile="C:\class&year.csv"
dbms=csv
out=myclass
replace;
getnames=yes;
run;
datafile=“c:\class2011csv”;
%let year=2011;
proc import datafile=“C:\class&year..csv”
dbms=csv
out=myclass
replace;
getnames=yes;
run;
SAS log:
NOTE: The SAS System was unable to open the
macro library referenced by the
SASMSTORE = libref MYMACS.
%test(x,y,z)
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.
Corrected code:
%macro test(vals);
%put &=vals;
%mend test;
%test(%str(x,y,z))
Email: Support@SAS.com
(919) 677-8008
http://support.sas.com/techsup
http://support.sas.com/resources