SAS Rename
2020-01-25 本文已影响0人
不连续小姐
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:
imageHappy Studying!