- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Searching a value in a column- JSL
Hi All,
Can anyone help me with the search for a particular value in a column and try to find the count of that value with the overall count? In the below example, I am trying to search for value "1" in B column. I found 3 occurences in 10 instances so C is marked with 30%. Similarly for A=2, I found 4 occurence of "1" in 12 instances, so C is marked with 33%.
A | B | C |
1 | 1 | 30% |
1 | 87 | |
1 | 90 | |
1 | 65 | |
1 | 1 | |
1 | 65 | |
1 | 3 | |
1 | 1 | |
1 | 34 | |
1 | 5 | |
2 | 1 | 33% |
2 | 5 | |
2 | 2 | |
2 | 47 | |
2 | 1 | |
2 | 54 | |
2 | 1 | |
2 | 85 | |
2 | 1 | |
2 | 1 | |
2 | 22 | |
2 | 21 |
Thank you
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
I think this should work:
col number(:b, :a, :b )/col number(:b, :a)
You need to take a look at the documentation on Col Number() in the Scripting Index
Help==>Scripting Index==>Col Number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
You can use the Tabulate Platform and specify the % Column Total as the statistic.
You can also create a new column and use the following formula to get the answer
Col Number( :b, :b ) / Col Number( :b )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
:b represents column "b", from the data table you listed in the original question. The formula,
Col Number( :b, :b) / Col Num( :b )
is interpreted as:
the count of all of the values in column b, for the current rows value of column b, divided by the total count of the values for column b.
In the example data you provided, the calculation for the first row would be:
The count of values found in column b, that match the value for column b. That is, the value of the first row for column b is "1", so it would count the number of "1"s found in column b, which is 8. It would then divide by the total number of the values found in column b, which is 22.
Concerning the Tabulate Platform, what you would do, is to change the modeling type of column b to Nominal, so Tabulate will treat the column as a grouping column. Then you would drag column b to the Drop Zone for Rows. I will then list out each of the values found for column b. By default, the statistic column that is listed is the count(N). To change it to the Column %, you would just drag the Column % statistic to the "N" column, and it would replace the statistic with the column %
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
I think this should work:
col number(:b, :a, :b )/col number(:b, :a)
You need to take a look at the documentation on Col Number() in the Scripting Index
Help==>Scripting Index==>Col Number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
HI
I checked the Col Number. Is this what you mean? but it won't work.
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
Col Number( :height,:height )/Col Num( :height )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Searching a value in a column- JSL
you misspelled "col number()" as "col num()"
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "thepercent",
formula( Col Number( :height, :height ) / Col Number( :height ) )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content