Page 1 of 1

Prefill roster column from another roster

Posted: October 3rd, 2023, 8:10 am
by blumski
Hi everyone,

I want to prefill a roster row from the firs roster based on a condition (If a row fills a condition, then add it to the second roster).
The picture shows the problem i get.
cap1.PNG
cap1.PNG (80.5 KiB) Viewed 3754 times
How to do for not having these empty rows ?

Here's my code :

Code: Select all

PROC GLOBAL

PROC APP_FF

PROC SCHOOL_ID
preproc
$ = curocc();

PROC SCHOOL_NAME
preproc
$ = getvaluelabel(SCHOOL_ID(curocc()));

PROC SCHOOL_ID_KNOWN
preproc
numeric i;

do  i = 1 while i <= count(APP000)
	if KNOWING(i) = 1 then
		KNOWN_SCHOOL_NAME(i) = SCHOOL_NAME(i);
		SCHOOL_ID_KNOWN(i) = SCHOOL_ID(i);
	endif;	
enddo;

I need your help

Re: Prefill roster column from another roster

Posted: October 3rd, 2023, 11:29 am
by justinlakier
You are setting KNOWN_SCHOOL_NAME and SCHOOL_ID_KNOWN at the indexes of the original, so it matches the original. Using a counter like this and indexing into the new table using the counter instead of "i", you can instead set the new known table from the bottom up with no gaps.

numeric numKnown = 0;
do  i = 1 while i <= count(APP000)
    if KNOWING(i) = 1 then
       
numKnown = numKnown + 1;
        KNOWN_SCHOOL_NAME(numKnown) = SCHOOL_NAME(i);
        SCHOOL_ID_KNOWN(numKnown) = SCHOOL_ID(i);
    endif
enddo;

Re: Prefill roster column from another roster

Posted: October 3rd, 2023, 1:51 pm
by blumski
Thank you so much justinlakier.

It worked

I'm so gratefull.