spssspss-modeler

Modify values programmatically SPSS


I have a file with more than 250 variables and more than 100 cases. Some of these variables have an error in decimal dot (20445.12 should be 2.044512).

I want to modify programatically these data, I found a possible way in a Visual Basic editor provided by SPSS (I show you a screen shot below), but I have an absolute lack of knowledge.

enter image description here

--- EDITED NEW DATA ---- Thank you for your fast reply.

The problem now its the number of digits that number has. For example, error data could have the following format:

Case A) 43998 (five digits) ---> 4.3998 as correct value. Case B) 4399 (four digits) ---> 4.3990 as correct value, but parsed as 0.4399 because 0 has been removed when file was created.

Is there any way, like:

IF (NUM < 10000) THEN NUM = NUM / 1000 ELSE NUM = NUM / 10000

Or something like IF (Number_of_digits(NUM)) THEN ...

Thank you.


Solution

  • there's no need for VB script, go this way:

    open a syntax window, paste the following code:

    do repeat vr=var1 var2 var3 var4.
    compute vr=vr/10000.
    end repeat.
    save outfile="filepath\My corrected data.sav".
    exe.
    

    Replace var1 var2 var3 var4 with the names of the actual variables you need to change. For variables that are contiguous in the file you may use var1 to var4.
    Replace vr=vr/10000 with whatever mathematical calculation you would like to use to correct the data.
    Replace "filepath\My corrected data.sav" with your path and file name.

    WARNING: this syntax will change the data in your file. You should make sure to create a backup of your original in addition to saving the corrected data to a new file.