Desktop productivity for business analysts and programmers

Rename Variable with invalid characters in data step

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Rename Variable with invalid characters in data step

Hi.

i have a variable named "((Branch_Nbr||' - ')||Branch_Cus" in a dataset  .

How can i change its name to "aaa" using the rename statement in datastep?

Thanks

Rafael

15         data Custs_Numerators_Income;

16              options obs=500;

17              set work.Custs_Numerators_Income

18              (

19                   rename=( "((Branch_Nbr||' - ')||Branch_Cus" = aaa )

                      __________________________________

                      214

                      23

ERROR 214-322: Variable name "((Branch_Nbr||' - ')||Branch_Cus" is not valid.

ERROR 23-7: Invalid value for the RENAME option.

20              );

21       

22              FORMAT Customer_Profit_Date DDMMYYS10.;

23              FORMAT Branch_Cust_End_Date DDMMYYS10.;

24       

25              /* rename ((Branch_Nbr||' - ')||Branch_Cus=aaa; */

26       

27                 

28       

29       

30       

31         run;

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.CUSTS_NUMERATORS_INCOME may be incomplete.  When this step was stopped there were 0 observations and 2

         variables.

WARNING: Data set WORK.CUSTS_NUMERATORS_INCOME was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds


Accepted Solutions
Solution
‎07-21-2015 07:52 AM
Super User
Posts: 9,867

Re: Rename Variable with invalid characters in data step

If that is real variable name .Try to Add N at then end of it .

options validvarname=any;

data Custs_Numerators_Income;

              options obs=500;

             set work.Custs_Numerators_Income

             (

                  rename=( "((Branch_Nbr||' - ')||Branch_Cus"N = aaa )

View solution in original post


All Replies
Super User
Super User
Posts: 7,720

Re: Rename Variable with invalid characters in data step

Hi

((Branch_Nbr||' - ')||Branch_Cus

Is not a valid variable name in SAS.  Do you mean you have a variable which has a label like the above?  If the variable is named that (and how?) then you might need:

options validvarname=any;


however more likely is that your talking about the label, in which case:

data want;

     set have;

     label variable "aaa";

run;

Solution
‎07-21-2015 07:52 AM
Super User
Posts: 9,867

Re: Rename Variable with invalid characters in data step

If that is real variable name .Try to Add N at then end of it .

options validvarname=any;

data Custs_Numerators_Income;

              options obs=500;

             set work.Custs_Numerators_Income

             (

                  rename=( "((Branch_Nbr||' - ')||Branch_Cus"N = aaa )

Occasional Contributor
Posts: 14

Re: Rename Variable with invalid characters in data step

Hi xia

Thank you very much.

That solved it

Thanks again

Rafael

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 1167 views
  • 0 likes
  • 3 in conversation