Prefill roster column from another roster

Discussions about CSEntry
Post Reply
blumski
Posts: 37
Joined: May 7th, 2018, 7:02 am

Prefill roster column from another roster

Post 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 3669 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
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: Prefill roster column from another roster

Post 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;
blumski
Posts: 37
Joined: May 7th, 2018, 7:02 am

Re: Prefill roster column from another roster

Post by blumski »

Thank you so much justinlakier.

It worked

I'm so gratefull.
Post Reply