banner



How To Change Variable Names To Numbers Sas

SAS : Variable Name having Spaces or Special Characters

This article may exist an eye-opener for you lot if you think a variable name cannot contain blanks or special characters except for the underscore in SAS. In this commodity, we would learn how we tin read a variable whose proper noun having spaces or special characters. Also, how to deal a variable name starts with a number. It also covers the same case with a dataset (table).

Why exercise nosotros demand to have spaces in a variable name?

If you apply teradata or any other database, you lot would encounter this problem very shortly if you have not encountered it yet. Many times, database column contains blanks or special characters. To read them in SAS, nosotros demand to know how to read variables having spaces in their names.

It is also required when we transpose our variables and the variable whose values name the transposed variables in the output data set contains special characters.

Let'due south create a sample data

data temp;
input var1;
cards;
1
2
;
run;

Rename the variable 'var1'  to 'variable i';

options validvarname=any;
data temp2;
set up temp;
rename var1 = 'variable 1'due north;
run;


The options validvarname=any; tells SAS to permit y'all to have variable proper name begin with or incorporate spaces, special characters or numbers.

Additionally, nosotros need to put variable proper name having spaces in quotes followed by the letter north .

Q. If i don't use VALIDVARNAME=ANY choice and employ just 'variable one'n , how SAS would take information technology?

Sol : SAS would return an error "variable proper noun is not valid" as SAS past default cannot contain blanks or special characters.

SAS : Variable Proper noun having Spaces


Tin variable proper noun starts with a number?

Yes, follow the lawmaking beneath -

options validvarname=any;
data temp2;
set temp;
rename var1 = '1variable'n;
run;


How about reading a dataset whose name having spaces?

The option VALIDMEMNAME= EXTEND allows you to read or access dataset (tabular array) whose proper name having spaces or special characters. In addition, we too need to put proper noun of variable in quotes followed by the letter north.

options VALIDMEMNAME=EXTEND;
proc impress information= 'price data'north;
run;

Nigh Writer:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of feel in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Man Resource.

Next → ← Prev

Source: https://www.listendata.com/2016/09/sas-variable-name-having-spaces.html

Posted by: henrypeargen.blogspot.com

0 Response to "How To Change Variable Names To Numbers Sas"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel