Page 1 of 1

Grouped data

Posted: Wed Nov 11, 2020 4:09 pm
by pdeli
I am trying to group data, but can't seem to get hold of it.

I have people's ages ranging from 22 to 69 years of age and I'd like to create a variable to group them from 10 to 10 years (e.g., 20-29; 30-39; etc., or 21-30; 31-40; etc.).

Here's what I did:
  1. Right-clicked on Age column header;
  2. Selected Transform;
  3. In field using transform selected Transform 1 (that already existed);
  4. Clicked on Edit button;
  5. There I set the following functions:
    • if $source <= 30 use '[21;30] years'
    • if $source > 30 use '[31;40] years'
    • if $source <= 40 use '[31;40] years'
    • if $source > 40 use '[41;50] years'
    • if $source <= 50 use '[41;50] years'
    • if $source > 50 use '[51;60] years'
    • if $source <= 60 use '[51;60] years'
    • else use '[61;70] years';
  6. Clicked on the down arrow in a circle;
  7. Clicked the up arrow in a circle to hide the setup
The result is that it works if age <= 30, but then everything else is put in the group [31;40] years.

Any ideas on how to get ages above 40 in the correct group?

Thanks in advance for you help.

----

I use Jamovi 1.6.6.0 on macOS Catalina (version 10.15.7), MacBook Pro (13-inch, 2019, Four Thunderbolt 3 ports), 2.8 GHz Quad-Core Intel Core i7, 16 GB 2133 MHz LPDDR3, Intel Iris Plus Graphics 655 1536 MB.

Re: Grouped data

Posted: Wed Nov 11, 2020 6:02 pm
by sbalci
Hi,
It will be better if you use & to define groups

if $source > 30 & $source <= 40 use '[31;40] years'

Re: Grouped data

Posted: Thu Nov 12, 2020 11:53 am
by pdeli
Hello @sbalci,

Thanks for your quick answer.

Unfortunately, I get a "The formula is mis-specified" when using your solution.

Re: Grouped data

Posted: Thu Nov 12, 2020 2:15 pm
by Ravi
Hi,

It should be (and instead of &):

Code: Select all

if $source > 30 and $source <= 40 use '[31;40] years'

Re: Grouped data

Posted: Thu Nov 12, 2020 4:17 pm
by pdeli
Hurray!!!!

It worked with "and" instead of "&"!

Thanks @Ravi and thanks to @sbalci :grinning: