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 all the values that are less than 1
Regroup all the values that are less than 1
Last edited by Adnane on December 26th, 2012, 3:26 am, edited 1 time in total.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Regroup all the values that are less than 1%
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;
if TABLE1(idx,0) = 1 then
TABLE1(idx,0) = 0;
inc(TABLE1(tblrow(TABLE1),0)); // increase the Others row
endif;
enddo;
- Attachments
-
- regroup.zip
- (4.07 KiB) Downloaded 433 times
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Regroup all the values that are less than 1%
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%
Perfect, great tools !!
thank you Mr Gregory.
thank you Mr Gregory.
Re: Regroup all the values that are less than 1
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
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
- Attachments
-
- regroup_2.rar
- (8.9 KiB) Downloaded 494 times
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Regroup all the values that are less than 1%
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;
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
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.
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.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Regroup all the values that are less than 1
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;
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;