2 users online | 2 Guests and 0 Registered

Should variable names be treated as case-sensitive?


Generally it is not necessary to worry about case when typing code and referring to variable names, dataset and library names etc., however a consistent coding style is always to be recommended.

This has two benefits: firstly it aids in readability, and secondly, there may be circumstances where the case may be an issue.

Consider the code:

data vars ;
  attrib a B c length = 4 ;
  a = 100 ;
  b = 200 ;
  c = 300 ;
run ;

which runs and produces a dataset.

a B c
100 200 300

 

Look at the properties of this dataset and you will see that the variable names are: a, B and c which is the case in which they were first referenced, and the system retains these.

Any subsequent code which references the second variable can use either b or B interchangeably.

If however the data is transposed:

proc transpose data = vars
                out = vars_t (rename = (_name_ = cvar))
		;
run ;

the output dataset now has the original variable names stored as values in the cvar variable: these values are now case-sensitive, and inconsistent.

cvar COL1
a 100
B 200
c 300
Author:
Alan D Rudland
Revision:
1.2
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags