Desktop productivity for business analysts and programmers

Renaming a variable in permanent data set

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 104
Accepted Solution

Renaming a variable in permanent data set

data hedis.ndcdiab;
    set hedis.ndcdiab;
  /*  ATTRIB NDC LENGTH = $11;  */
    NDC = put('NDC Code'n, $11.);
	run;

 

NDC Code is a column in the data set ndcdiab.  I am trying to rename NDC Code to just NDC_Code (with underscore in between).  How would I go about doing this in the above statement?


Accepted Solutions
Solution
4 weeks ago
Super User
Posts: 13,365

Re: Renaming a variable in permanent data set

The "best practice" would be to either read the data originally without the name literal or to use Proc Datasets to modify the data set by renaming the variable.

 

Your approach with the data step reads the entire data set which may be very time consuming and if you make an error could corrupt the data.

 

 

Proc datasets library=hedis nolist;

   modify ndcdiab;

      rename 'NDC Code'n=Ndc_code;

quit; /* note QUIT, to end the procedure*/

 

In a data step you could also use the Rename statement.

View solution in original post


All Replies
Solution
4 weeks ago
Super User
Posts: 13,365

Re: Renaming a variable in permanent data set

The "best practice" would be to either read the data originally without the name literal or to use Proc Datasets to modify the data set by renaming the variable.

 

Your approach with the data step reads the entire data set which may be very time consuming and if you make an error could corrupt the data.

 

 

Proc datasets library=hedis nolist;

   modify ndcdiab;

      rename 'NDC Code'n=Ndc_code;

quit; /* note QUIT, to end the procedure*/

 

In a data step you could also use the Rename statement.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 96 views
  • 0 likes
  • 2 in conversation