SAS Rename

SAS Day 52

Once I use SAS proc import a Special Adverse Event dataset, everything looks good, except the variable name was directly from excel and has space and special characters like "/" (EOI/ Search)

Little Challenge: How to Rename a variable with space or special characters?

Basic Rename Syntax:

*1. within dataset
data a;
set a;
rename old_name=new_name;
run;

*2. on the first line;
data a(rename=old_name=new_name);
set a;
run;

Although this approach works majority of the time, it won't work with the special characters or there are spaces in the variable name.

Advanced Rename Syntax with Special Characters:

data a;
set a;
rename "old name"n= new_name;
run;

*example;

data sm;
set sm;
rename 'eoi/search strategy'n=eoi_search;
rename 'MedDRA Code'n=medra;
rename  'MedDRA PT'n=pt;
run;

Output:

Happy Studying!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章