Updated March 16, 2023
Introduction to SAS Rename
The SAS rename is the feature for changing the variable’s name or the variable list already declared in the SAS input data set or in the data step created by the new set of variables. It allows you to replace old variable names in programming statements by changing one or more variables written into the output directory.
Overview of SAS Rename
The rename is a type of function that can be used for more than one variable in a SAS dataset, and SAS users will refer to it as such. Renaming column variables will use the datas like NHANES, but the code of the data registration is not correctly called for the column names. This is nearly impossible for the recoding data columns. It decodes the datas by using the more straightforward format that assists and is associated with the sequence number of the SAS issues and the spaces between the original data content and duplicate contents.
We can enclose the text from the data label using the single and double quotation Rename option, which tells SAS to change the name of the two variables from within the parentheses as long as the space separates each pair of the old and new variables.
How to Use Variables SAS Rename?
We can use the rename function with the SAS dataset for the column variables from the NHANES data, but the data code is registered incorrectly. The specified column names are so long, and it’s nearly impossible to recode the data from one format to another more straightforward format. Respondent and correct sequence numbers to the ID with SAS having issues on the spaces from the original name to the duplicate name with exact sequence steps.
Using the names and Rename statement for calling the labels and looking at the VIEWTABLE window on the SAS can be parsed out of the command line representing variable names. To Run the PROC data contents from the dataset, which helps to see the labels and execute the statements if only the specified condition is true or else it will come out of the loop or terminate the loop. Next, we will continue using the same dataset for the other data variables, both user-defined and pre-defined variables.
Steps to create the variable SAS rename:
1. Navigate to the below link.
2. https://odamid-apse1-2.oda.sas.com/SASStudio/main?locale=en_US&zone=GMT%252B05%253A30&ticket=ST-37948-C1oNdCTb6IyjF7W0KIdl-cas
3. After successfully logging in, type the below code for creating the data set and Proc SQL.
4. data First;
5. input emp_id $ emp_name $ emp_dob $;
6. datalines;
7. 1234 Raman 10051989
8. 5 Srew 1234521
9. 6 rtw 10454
10. ;
11.
12. proc sql;
13. insert into First
14. set emp_id=1234,
15. emp_namename=’Raman’,
16. emp_dob=10051989
17.
18. the title “Welcome To My Domain”;
19. select emp_name format=$20.,
20. emp_id format=$15.,
21. emp_dob format=comma15.0
22. from First;
Output:
It helps create the dataset along with PROC SQL with the variable declaration.
Then by using the below code to change the variable or column name like emp_name, it is changed to name by using the below code.
Code:
data First;
set First;
rename emp_name = Name;
run;
Output:
The name is successfully changed and displayed on the output tab.
SAS Rename Statement
The SAS rename statement is specified with the new names for the required variables in the output console for SAS data sets; it is valid in the DATA step. The statement category is the CAS, denoted by the data and information, and it’s declared using the Declarative type. Rename parameters like old and new names with the specified arguments and enable the name change for one or more variables on the list that will combine the variables and variable lists. The new variable name is declared by the user end. Then, it will be executed and written into the output directory dataset by using the old variable names in programming statements for the current data step. Rename the values and apply them to all the output data sets.
Generally, the Rename statement, which affects the datasets, is already opened in the output mode, which must continue to rename the old variable names in the programming statements for the current DATA step. After the output data is created, the SET statement’s new variable names rename the input data set variables. We can set and use the new names in the programming statements of the current data step of renaming the variables, which helps to write the datas in the file management task. Using the datasets procedure or accessing the variables through the SAS windowing interface for the method is more straightforward and does not require data step processing. Using the change statement, we can call the datasets procedure for renaming the variables for setting the same library in the SAS.
Example of SAS Rename
Given below is the example of SAS Rename:
Code:
DATA Second;
INPUT Rollno $ ID $ Name $;
DATALINES;
001 9184321123 Siva
002 9212434 Raman
003 9351251 Sivaraman
;
RUN;
PROC SQL;
CREATE TABLE bckup AS
SELECT * FROM Second;
QUIT;
PROC PRINT vars = bckup;
RUN;
Output:
Code:
data Second;
set Second;
rename ID = MobileNumber;
run;
Output:
- The above codes are the primary example for renaming the variables, columns, and data types.
- Here the Rename option uses the dataset option to pass the input dataset along with the variable SET statement and the output dataset.
- Create a table on the proc sql using the rename keyword; we can rename the old value to a new value.
Conclusion
The SAS Rename is the type of option that can be used in the dataset option for both the input dataset, which passed the SET statement, and the output dataset. The Rename option will follow the keep and drop options using the existing variable name.
Recommended Articles
This is a guide to SAS Rename. Here we discuss the introduction, how to use variables SAS rename? And examples, respectively. You may also have a look at the following articles to learn more –