views:

54

answers:

1

Hi People, I am curently busy with bulding a synthax document in SPSS and have a column of variable strings that consists of approximately 40 lines (it will be much much more in coming week). SPSS has a nice way of creating it (can be seen here :) http://vault.hanover.edu/~altermattw/methods/stats/reliable/reliability-1.html) but it can be done per one variable at a time which is possible to automatize.

I am a total beginner (I wouldn't mind if you would call me n00b) at search&replace with reqular expressions in notepad++ but I can use the extended search function as a basic user :P

The data contains scores Likert scale (from 1-7) and I would like to reverse it to do some tests.

For example: my variable name on the line is q_4_SQ001 and the sline in synthax editor is q_4_SQ001=COMPUTE q_4_SQ001r=8-q_4_SQ001.

My question so far is thus:

How can I convert a line containing a unique variable name into it's revers formula?

So in this case, how can I replace the following lines:

q_4_SQ001
q_4_SQ002
q_4_SQ003
q_4_SQ004

into the synthax given under:

COMPUTE q_4_SQ001r=8-q_4_SQ001.
COMPUTE q_4_SQ002r=8-q_4_SQ002.
COMPUTE q_4_SQ003r=8-q_4_SQ003.
COMPUTE q_4_SQ004r=8-q_4_SQ004.

Please remark the dots in the end of each line I did this manually to give you an impression of what I would like to achieve. My data set has different questions and different variable strings so I would like to make my life a bit easier right now :P

I also tried recording and running a macro as stated in here (http://stackoverflow.com/questions/2467875/notepad-replace-all-regular-expression-start-of-the-line-and-end-of-the-line) but that still is pretty time consuming since I have to do each line manulally and clean up with extended search in the end.

Wouldn't it be easier to convert each line?

Thanks a bunch in advance :)

A: 

Funny, Notepad++ works under Wine, as I just found out ;)

New file, inserted:

q_4_SQ001
q_4_SQ002
q_4_SQ003
q_4_SQ004

Select all (CTRL+A), replace (CTRL+R).

Tick Regular Expr, stick ^(.*)$ in the "find" bit (first textbox), and COMPUTE \1r=8-\1. in the "replace" bit (second textbox). Hit the Find button, and then the Replace Rest button.

Parenthesis () around a pattern cause the pattern to be "memorised", each set of parenthesis available to the replacement pattern via \1, \2, etc.

After the replace, I got:

COMPUTE q_4_SQ001r=8-q_4_SQ001.
COMPUTE q_4_SQ002r=8-q_4_SQ002.
COMPUTE q_4_SQ003r=8-q_4_SQ003.
COMPUTE q_4_SQ004r=8-q_4_SQ004.

Which I assume is what you wanted. Enjoy.

mfontani
This helped :) Thank you very much! I can't vote UP due to lack of UP points I got.
lightblack