Announcement

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

  • Label define Code Block

    Hi all,

    I was wondering if there was a quick way to reformat the code blocks I currently have in the American Time Use Survey Do-file.

    Code:
    label define labelteabsrsn -1 "Blank" -2 "Don't Know" -3 "Refused" 1 "On layoff (temporary or indefinite)" 2 "Slack work/business conditions" 3 "Waiting for a new job to begin" 4 "Vacation/personal days" 5 "Own illness/injury/medical problems" 6 "Childcare problems" 7 "Other family/personal obligation" 8 "Maternity/paternity leave" 9 "Labor dispute" 10 "Weather affected job" 11 "School/training" 12 "Civic/military duty" 13 "Does not work in the business" 14 "Other"
    Code:
    label define labelteernhry
    -1 "Blank"
    -2 "Don't Know"
    -3 "Refused"
    1 "Paid hourly"
    2 "Not paid hourly"
    
    label define labelteernper
    -1 "Blank"
    -2 "Don't Know"
    -3 "Refused"
    1 "Hourly"
    2 "Weekly"
    3 "Bi-weekly"
    4 "Twice monthly"
    5 "Monthly"
    6 "Annually"
    7 "Other"
    
    label define labelteernrt
    -1 "Blank"
    -2 "Don't Know"
    -3 "Refused"
    1 "Yes"
    2 "No"
    So the first code block is is what I have fixed by hand in order for the code to run. The second code block is what has NOT been fixed by me yet, and does not run. I was wondering if there was a quick way to run the second code block without me having to fix every code block (there are approximately 1000 more lines that needs to be fixed). Any help would be greatly appreciated.

  • #2
    Try replace (Ctrl+H), click regular expressions and replace

    Code:
    ^$
    with

    Code:
    ;
    Then, add the one line

    Code:
    #delimit ;
    at the top of the code blocks and

    Code:
    ;
    #delimit cr
    after the last line that defines an integer to text mapping.

    Your code should then look like this:

    Code:
    #delimit ;
    label define labelteernhry
    -1 "Blank"
    -2 "Don't Know"
    -3 "Refused"
    1 "Paid hourly"
    2 "Not paid hourly"
    ;
    more code here
    label define labelteernrt
    -1 "Blank"
    -2 "Don't Know"
    -3 "Refused"
    1 "Yes"
    2 "No"
    ;
    #delimit cr

    Comment

    Working...
    X