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!

Post navigation

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: