BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Batman
Quartz | Level 8

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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)Smiley SadColumn).

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.

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

best is a numeric format, so you cannot use the quotes

--
Paige Miller
Batman
Quartz | Level 8

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

Reeza
Super User

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)Smiley SadColumn).

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.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1724 views
  • 0 likes
  • 3 in conversation