Combine answers from previous question.

Discussions about CSEntry
Post Reply
Nikola
Posts: 27
Joined: December 24th, 2021, 4:30 am

Combine answers from previous question.

Post by Nikola »

I would like to set the Household ID code automatically by combining the Province code and District code. How to combine answers from the previous questions?

(numeric) If the Province code is 1 and the District code is 23, the Household ID should come automatically as 123.
(Alphanumeric) If the Province code is A and the District code is 23, the Household ID should come automatically as A23.

For example, if I want to set the Household ID code automatically as the same as the Province code, the logic is:

PROC HOUSEHOLD_ID
Preproc
$ = PROVINCE;

Like this way, how can I preset the answer by combining answers from the previous questions?
Gregory Martin
Posts: 1812
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Combine answers from previous question.

Post by Gregory Martin »

There are a variety of ways to do this, but here are some examples. You can use arithmetic for simple math combinations:
HOUSEHOLD_ID = PROVINCE * 100 + DISTRICT;
For strings, you can combine variables with maketext:
HOUSEHOLD_ID = maketext("%s%02d", PROVINCE, DISTRICT);
Nikola
Posts: 27
Joined: December 24th, 2021, 4:30 am

Re: Combine answers from previous question.

Post by Nikola »

Thank you.
Post Reply