Welcome, Guest
Username: Password: Remember me

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

How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 3 weeks ago #86486

  • amoswagon
  • amoswagon's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
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!!
The administrator has disabled public write access.

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86511

  • tfj
  • tfj's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 80
  • Thank you received: 6
  • Karma: 5
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:
The administrator has disabled public write access.

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86519

  • amoswagon
  • amoswagon's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
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.
The administrator has disabled public write access.

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86521

  • tfj
  • tfj's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 80
  • Thank you received: 6
  • Karma: 5
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 administrator has disabled public write access.
The following user(s) said Thank You: amoswagon

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86522

  • amoswagon
  • amoswagon's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 20
  • Karma: 0
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!
The administrator has disabled public write access.

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86527

  • tfj
  • tfj's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 80
  • Thank you received: 6
  • Karma: 5
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 administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu, amoswagon

Re: How to create a calculated 'Age Ranges' question out of 'Age' numeric? 2 years 2 weeks ago #86560

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5333
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.152 seconds
Donation Image