If I am filtering a variable with numbers with a "Best12." format, does it matter whether I enclose the filter value in quotes? In other words,
If [varname] = '20'
or
If [varname]=20
It didn't quite work, look at your log closely, specifically:
NOTE: Character values have been converted to numeric values at the places given by: (Line)Column).
45:22
The general rule is don't have these in your log.
If it works, why does it matter?
Because then you can't tell the difference between a real error and where you made a decision to convert data.
best is a numeric format, so you cannot use the quotes
That is what I assumed, but the character filter in line 45 below seems to work. FYI, I'm asking this mundane question to document steps in a program.
30 data _null_;
31 set test1;
32 put termination_code;
33 run;
10
10
10
10
10
20
10
20
20
20
NOTE: There were 10 observations read from the data set WORK.TEST1.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
2 The SAS System 10:03 Wednesday, April 18, 2018
34
35 proc contents data=test1 noprint out=var_dat;
36 run;
NOTE: The data set WORK.VAR_DAT has 1 observations and 41 variables.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.04 seconds
cpu time 0.06 seconds
37
38 data _null_;
39 set var_dat(keep=NAME TYPE LENGTH FORMAT);
40 put _all_;
41 run;
NAME=Termination_Code TYPE=1 LENGTH=8 FORMAT=BEST _ERROR_=0 _N_=1
NOTE: There were 1 observations read from the data set WORK.VAR_DAT.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
42
43 data _null_;
44 set test1;
45 if termination_code='10' then put termination_code;
46 run;
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
45:22
10
10
10
10
10
10
NOTE: There were 10 observations read from the data set WORK.TEST1.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
It didn't quite work, look at your log closely, specifically:
NOTE: Character values have been converted to numeric values at the places given by: (Line)Column).
45:22
The general rule is don't have these in your log.
If it works, why does it matter?
Because then you can't tell the difference between a real error and where you made a decision to convert data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.