How to create a calculated 'Age Ranges' question out of 'Age' numeric?

More
5 years 1 month ago #86486 by amoswagon
amoswagon created the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
Hopefully this is a simple question with a simple enough answer.
How to create a calculated 'Age Ranges' question out of 'Age' numeric?

I want a survey to include the following:

1: What is your age? _____ (numeric)
2: Age Range: (hidden)
-under 20
-21 to 40
- 41 to 60
- 61 or more

I want people's answers to question 1 to fall into the correct bucket of question 2 and be stored just as if I asked the question.

Thanks!!

Please Log in to join the conversation.

More
5 years 1 month ago #86511 by tfj
tfj replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
amoswagon:

I have put together a simple survey (attached) that may be what you are looking for. I based it upon the excellent example of the BMI calculation that tmswhite put together in his sample surveys that display how the Expression Manager works. (For example, you might look at the documentation under "Tailoring/Piping.")

I slightly changed your specifications to account for someone who is 20 years old, as you will see in the coding for the 2nd question.

tfj
Attachments:

Please Log in to join the conversation.

More
5 years 1 month ago #86519 by amoswagon
amoswagon replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
This is extremely helpful - thank you.
Is it possible to put the data in a single choice question with answer choices predefined?
In your example the data is stored as a Open text response, I'd like it to be stored with Answer codes as A1 (under 20) A2 (20-40) and so on...

I appreciate the efforts you put in your answer and example.

Please Log in to join the conversation.

More
5 years 1 month ago #86521 by tfj
tfj replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
amoswagon:

I'm not sure that I have understood your requirement, but you could change the coding in the second question to this:

{if(Age <= 20, 'A1', if(Age < 41, 'A2',if(Age < 61, 'A3','A4')))}

and then hide the question, (in the Advanced settings).

tfj
The following user(s) said Thank You: amoswagon

Please Log in to join the conversation.

More
5 years 1 month ago #86522 by amoswagon
amoswagon replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
This is how you built it:
1) Age (numeric)
2) AgeRange*(Equation)

*The calculated ranges are stored in AgeRange question

This is how I want it:
1) Age (numeric)
2) AgeRange*(Equation)
3) AgeGroups (single choice- hidden) with the following options A1 (under 20) A2 (21-40) and so on...

Once a user enters his/her age, the data will be recorded in the AgeGroups question as if he/she answered the Single Choice question.

I want to save the data as a single choice, because it gives more flexibility in terms of charting and additional analysis in SPSS.

I hope I was more clear this time!
Thank!

Please Log in to join the conversation.

More
5 years 1 month ago #86527 by tfj
tfj replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
amoswagon:

Seems to me that the hidden equation question fulfills your requirement, when you change my original one to

{if(Age <= 20, 'A1', if(Age < 41, 'A2',if(Age < 61, 'A3','A4')))}

and make it hidden and not mandatory.

It puts "A1," "A2", "A3", or "A4" into a separate field, without asking the user. You can then export the table to SPSS.

I'm sure someone else will understand your requirement better than I have. I'm sorry I couldn't be of more help.

tfj
The following user(s) said Thank You: DenisChenu, amoswagon

Please Log in to join the conversation.

More
5 years 1 month ago #86560 by Mazi
Mazi replied the topic: How to create a calculated 'Age Ranges' question out of 'Age' numeric?
Great example, tjf. Can you please add it to docs.limesurvey.org/Expression+Manager+E...ples_for_Expressions and also attach your survey there for testing?

This would help other users a lot.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!