Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while renaming a group of variables

    Dear all,

    I am having a problem while renaming a group of variables. I bet the problem is generated by some simple error that I am unable to see. I am trying to rename a group of 6 variables using the code:

    Code:
    ren (SECTIONIIPOSTDEALACTIVITIES AJ AK AL AM AN) ///
    (kttoacquirer_local_market kttoacquirer_managerial_skills kttoacquirer_RD kttoacquirer_productprocess_design kttoacquirer_marketing kttoacquirer_distribution)
    but I keep getting the message:

    Code:
    oldnames and newnames do not match
        You specified 1 pattern or name for oldname and 3 patterns or names for newnames
    .

    Does someone know why?

    Many thanks in advance for your help.

    Riccardo

  • #2
    The error message does not tell you of the real problem: one intended name is too long.

    Code:
    foreach n in kttoacquirer_local_market kttoacquirer_managerial_skills kttoacquirer_RD kttoacquirer_productprocess_design kttoacquirer_marketing kttoacquirer_distribution { 
         di "`n' " length("`n'")  
    } 
    
    kttoacquirer_local_market 25
    kttoacquirer_managerial_skills 30
    kttoacquirer_RD 15
    kttoacquirer_productprocess_design 34
    kttoacquirer_marketing 22
    kttoacquirer_distribution 25

    Comment


    • #3
      Variable names can be up to 32 characters, but
      Code:
      kttoacquirer_productprocess_design
      has 34 characters. This is a likely reason for the error message you got.
      BTW: Why use variable names this length? In many cases they are abbreviated, anyway.

      Comment


      • #4
        Oh, I see. Thank you so much Nick!

        Comment


        • #5
          Hi Svend,

          for some reason I didn't see your answer. Many thanks for the response. Yes, that was definitely the problem. I used long variable names because I didn't want to define labels - but next time perhaps I should do that!

          Riccardo

          Comment

          Working...
          X