Multiple disaggregate

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
etuser
Posts: 85
Joined: September 3rd, 2019, 5:57 am

Multiple disaggregate

Post by etuser »

Dear Sir,

I am using Cspro 7.3 and I want to split a multiple response to discrete variables. For example, i have a multiple checkbox variable alpah variable which takes a 2 digit and 20 choices which means a maximum of 10 responses to the variable called Q001 , lets say 050912 in Q001 and now my clients wants to have 10 new variables created and response "05" on Q001_5 "09" on Q001_9 ...... is there any simple way other than "if else" for the whole variable?

thanks
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Multiple disaggregate

Post by aaronw »

Yes, you're going to have create the 10 new variables and then check whether the value exists or not. If you're doing this in data entry I would suggest not adding these new variables to the form. The logic will look similar to this:
// Process answers into Yes(1)/No(0) answers
if ischecked("A", TOILET_QUESTION) <> 0 then
   
TOILET_OPTION_1 = 1;
else
   
TOILET_OPTION_1 = 0;
endif;
etuser
Posts: 85
Joined: September 3rd, 2019, 5:57 am

Re: Multiple disaggregate

Post by etuser »

Dear Arron,

Thank you very much, i tried your hint and re-work but still have one difficulty , since my choices are in alpha checkbox and numbers , I can write

Do varying i= 1 until i > length(strip(TOILET_QUESTION))
if ischecked(maketext("%02d",i), TOILET_QUESTION) <> 0 then
// since i already creating a new variable like TOILET_QUESTION_1, TOILET_QUESTION_2 ........ in my dictionary and
// if there are a way to write a name of a new variable based on the existing , things will be much simpler but failed to compile,
// it says TOILET_QUESTION_"i" not found
TOILET_QUESTION_"i" = 1

Endif;
Enddo;
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Multiple disaggregate

Post by aaronw »

The issue you're having is referencing the correct variable. We can use maketext to create "TOILET_QUESTION_1", "TOILET_QUESTION_2", etc. However, these are strings and not dictionary symbols, so we cannot assign a value to them. You can use getsymbol to get the current procs symbol, but in this scenario the logic isn't going to be any better.

The above code snippet is for CSPro 7.4. In CSPro 7.3 replace ischecked with pos.
Post Reply