Page 1 of 1
Regroup all the values that are less than 1
Posted: December 17th, 2012, 4:06 am
by Adnane
hello to all,
Is there any way to regroup all the values that are less than 1 automatically ?
for exemple: I have in my output tables as following :
Nationalité:
frence =1
Germany=1
Americaine=1
Italian=10
I want to make this :
Nationalité:
Italian=10
Other=3
See attachement :
Regroup values(Table).rar
Re: Regroup all the values that are less than 1%
Posted: December 19th, 2012, 10:00 am
by Gregory Martin
This is possible, though it requires some programming. I've attached an example where you can see what I've done. Basically, I added Others as a value to the value set, at the end. And then in your table's PostCalc logic I go through all the cells of your table, and when there is only a value of 1, I change it to 0 and increment the Others category. And then I format the stub, specifying that I want to "Hide when All Cells in Row are Zero." This will give you your desired table. Here is the logic:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
if TABLE1(idx,0) = 1 then
TABLE1(idx,0) = 0;
inc(TABLE1(tblrow(TABLE1),0)); // increase the Others row
endif;
enddo;
Re: Regroup all the values that are less than 1%
Posted: December 19th, 2012, 10:01 am
by Gregory Martin
Also, to do this I had to add idx as a temporary numeric variable to the logic (in the PROC GLOBAL section). To do this, press Control+L while viewing your table and you will have access to your table logic so that you can add the variable to PROC GLOBAL.
Re: Regroup all the values that are less than 1%
Posted: December 23rd, 2012, 5:31 am
by Adnane
Perfect, great tools !!
thank you Mr Gregory.
Re: Regroup all the values that are less than 1
Posted: December 24th, 2012, 4:39 am
by Adnane
Another small problem with the same function of regroup value,
I add another column in the same table, which represents the percent, then I notice that the function work well only with the
column of numbers but not with percent,
see the example
Re: Regroup all the values that are less than 1%
Posted: December 25th, 2012, 12:19 pm
by Gregory Martin
You can add percents to your table, but then you have to switch the values for both the counts and the percents columns, like this:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
if TABLE1(idx,0) = 1 then
TABLE1(idx,0) = 0;
TABLE1(idx,1) = 0;
inc(TABLE1(tblrow(TABLE1),0));
inc(TABLE1(tblrow(TABLE1),1));
endif;
enddo;
Re: Regroup all the values that are less than 1
Posted: December 27th, 2012, 8:49 am
by Adnane
To understand more this function,
please could you rewrite me this function but this time for exemple to regroup all valeus that are less than 3 ?
I tried but I did not come to found,
thank you very much sir gregory.
Re: Regroup all the values that are less than 1
Posted: February 19th, 2013, 11:01 am
by Gregory Martin
I answered this over email, but for the sake of anyone else, here is how you would regroup values less than 3:
do idx = 1 while idx <= ( tblrow(TABLE1) - 1 )
if TABLE1(idx,0) < 3 then
inc(TABLE1(tblrow(TABLE1),0),TABLE1(idx,0));
inc(TABLE1(tblrow(TABLE1),1),TABLE1(idx,1));
TABLE1(idx,0) = 0;
TABLE1(idx,1) = 0;
endif;
enddo;