Create new binary variable on converting

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Create new binary variable on converting

Post by yanina »

Dear Master
Josh, Gregory

Need your insight please.

During converting to excel or spss, how the logic to create new variable base on data entry result?

I have a program that already entry.
Variable Q1x
: as roster form, with 10 Occurrences. Allow value 1 - 10.

I want the result after converting would create binary variables like Q1_1, Q1_2,
... till Q1_10. The result should be ready to tabulate, or at least able to open on excel spreadsheet.

On SPSS I ussually using syntax 'recode' or 'compute' of that Q1x to new binary variables. Then this new variables created just ready to tabulate.

I believe CSPro can handle this. What its name Batch logic ?

Thank you very much master for your kind help.


Yanin
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Create new binary variable on converting

Post by josh »

Yes, you could use a batch edit application for this. For details on how to create a batch edit application see the help.

Basically you would add the variables Q1_1, Q1_2... in your dictionary. Either add them to a new not required record or add the them to the END of an existing record. If you add them in the middle of a record it will cause start positions of existing items to change and no longer match your data. You would write logic in your batch edit program that would assign the values of the new variables Q1_1, Q1_2... from the repeating variable Q1x e.g.:

PROC Q1_1
Q1_1 = ...

Use the existing data file as the input file to your batch program and set the output file to a new file. After running the batch edit program the output file will contain the new values and you can use that new data file to export.
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: Create new binary variable on converting

Post by yanina »

Thanks Josh for your insight.
I will learn how to do it, and back if any.

Yanin
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: Create new binary variable on converting

Post by yanina »

Dear Josh

I just tried using batch to convert Q1 to binary base on Q1x. What a great application :).
Yes, this can help much my time on cleaning the data.

My questions:
The Logic have to assign on ORD file to each variable that I want to convert, right ?
So if I have Q2x, Q3x,Q4x .... Q100x and want to convert the entry result to binary 1 0, I have to create all of them on Active Dictionary ?

Could you please take a look my logic on Q1 that I put on ORD batch file.

Huge thanks Josh.

for Q1

Code: Select all

numeric i, linenumber;linenumber=$; 
do  i = 1 while i <= 10             
if $(i) = linenumber then Q1(linenumber) = 1; 
else endif;
enddo; 
 
do  i = 1 while i <= maxocc(Q1000)Q1(i) = NOTAPPL;
enddo; 
 
do  i = 1 while i <= totocc(Q1X000)
if $(i) in 1:maxocc(Q1000)then  
Q1($(i)) = 1;endif;
enddo; 
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Create new binary variable on converting

Post by josh »

The ord in a batch application is like the form file for the data entry application. You only need one ord file for your application. Within that ord file you will see each of the variables in your dictionary.

I'm not able to follow your logic without understanding the structure of your dictionary or knowing which proc it is in.
Post Reply