Date: Wed, 5 Aug 1998 17:36:38 -0700
Reply-To: Jedd Parker <JeddParker@FAIRISAAC.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Jedd Parker <JeddParker@FAIRISAAC.COM>
Subject: Getting rid of Null characters
Content-Type: text/plain; charset="iso-8859-1"
Greetings All,
I am trying to get rid of null characters (or unprintable characters) in
a SAS dataset that I want to print.
If anyone knows how to do this in VI or some such UNIX utility that
would be great, in the mean time I
am attempting to run a little macro I have come up with. I have what
appears to be 2 problems:
1) It appears that the macro only gets called once, not the 57 time it
should for the 57 obs in TMPJDP2.
2) The variable NAME gets passed to the macro as NAME, not the value in
NAME...
I have included the code and the log below.
Thanks for any help!
******************************
Jedd L. Parker
jeddparker@fairisaac.com
******************************
CODE:
/*
This Randomly picks 1000 observations from a dataset,
cleans unprintable characters from all CHAR variables,
then print the dataset
*/
options linesize=132 mprint replace merror mlogic
source2 pagesize=60 errors=20 symbolgen center ;
libname jdx v609 './';
%macro cleanit(VARNM);
data jdx.tmpjdp;
set jdx.tmpjdp;
tmpvar = upcase(&VARNM);
tver1 = verify(tmpvar,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
!@#$%^&*()_+=-?/>.<,":;|\}]{[');
if (tver1) then &VARNM = '*';
%mend cleanit;
proc contents data = jdx.rectype1;
run;
data jdx.tmpjdp (drop=x1);
set jdx.rectype1 ;
x1 = ranuni(129876);
if x1 < 0.000788231220;
run;
proc sql;
create table jdx.tmpjdp2 as
select distinct NAME
from dictionary.columns
where MEMNAME = "TMPJDP" and TYPE="char"
;
proc print data=jdx.tmpjdp2;
run;
data tmp2;
set jdx.tmpjdp2;
%cleanit(name);
run;
LOGFILE:
7 %macro cleanit(VARNM);
8
9 data jdx.tmpjdp;
10 set jdx.tmpjdp;
11 tmpvar = upcase(&VARNM);
12 tver1 =
verify(tmpvar,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
!@#$%^&*()_+=-?/>.<,":;|\}]{[');
13 if (tver1) then &VARNM = '*';
14 %mend cleanit;
15
16 proc contents data = jdx.rectype1;
17 run;
NOTE: PROCEDURE CONTENTS used:
real time 0.07 seconds
cpu time 0.03 seconds
NOTE: The PROCEDURE CONTENTS printed pages 1-3.
18
19 data jdx.tmpjdp (drop=x1);
2 The SAS
System 17:01 Wednesday, August 5, 1998
20 set jdx.rectype1 ;
21 x1 = ranuni(129876);
22 if x1 < 0.000788231220;
23 run;
NOTE: The data set JDX.TMPJDP has 960 observations and 114 variables.
NOTE: DATA statement used:
real time 1:55.26
cpu time 31.61 seconds
24
25 proc sql;
26 create table jdx.tmpjdp2 as
27 select distinct NAME
28 from dictionary.columns
29 where MEMNAME = "TMPJDP" and TYPE="char"
30 ;
NOTE: Table JDX.TMPJDP2 created, with 57 rows and 1 columns.
31
NOTE: PROCEDURE SQL used:
real time 0.07 seconds
cpu time 0.02 seconds
32 proc print data=jdx.tmpjdp2;
33 run;
NOTE: The PROCEDURE PRINT printed pages 4-5.
NOTE: PROCEDURE PRINT used:
real time 0.00 seconds
cpu time 0.00 seconds
34
35 data tmp2;
36 set jdx.tmpjdp2;
37 %cleanit(name);
MLOGIC(CLEANIT): Beginning execution.
MLOGIC(CLEANIT): Parameter VARNM has value name
NOTE: The data set WORK.TMP2 has 57 observations and 1 variables.
NOTE: DATA statement used:
real time 0.05 seconds
cpu time 0.01 seconds
MPRINT(CLEANIT): DATA JDX.TMPJDP;
MPRINT(CLEANIT): SET JDX.TMPJDP;
SYMBOLGEN: Macro variable VARNM resolves to name
MPRINT(CLEANIT): TMPVAR = UPCASE(NAME);
MPRINT(CLEANIT): TVER1 =
VERIFY(TMPVAR,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
!@#$%^&*()_+=-?/>.<,":;|\}]{[');
SYMBOLGEN: Macro variable VARNM resolves to name
MPRINT(CLEANIT): IF (TVER1) THEN NAME = '*';
MLOGIC(CLEANIT): Ending execution.
38 run;
3 The SAS
System 17:01 Wednesday, August 5, 1998
NOTE: Numeric values have been converted to character values at the
places given by: (Line):(Column).
37:1
NOTE: Character values have been converted to numeric values at the
places given by: (Line):(Column).
37:183
NOTE: The data set JDX.TMPJDP has 960 observations and 117 variables.
NOTE: DATA statement used:
real time 0.22 seconds
cpu time 0.09 seconds