LoadCase Function

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

LoadCase Function

Format
b = loadcase(dictionary_name『,id1,...,idN』);
Description
The loadcase function reads a specified case from an external file into memory. Once the case is
loaded, all variables defined in the corresponding dictionary are available for use.
The dictionary name must be supplied and refers to an external dictionary associated with your
application.
The optional list of ID variables, id1 ... idN, specifies the list of variables that will identify the
case to load from the external file. This process is similar to matching files on the basis of key
variables in statistical and database software packages. Each of the variables in the list must be
defined in a dictionary or working storage. The combined length of the variables in the list must
equal the length of the case IDs defined for the external dictionary. The function concatenates the
variables in the ID list to form a string. It then loads from the external file the case whose case
identifier matches the string constructed from the list.
If no ID list is provided, the next logical case in the external file will be loaded. The next logical
case is defined as the case with the next sequential case identifier (in ascending order). This will
not necessarily be the next case in physical sequence in the file.
(In versions of CSPro prior to 7.0, calling this function would automatically open an external
file. The function no longer does this, so if you call close on an external dictionary, you must
open it manually before calling this function.)
Return Value
The function returns a logical value of 1 (true) if the case was loaded successfully and 0 (false)
otherwise.
Example
if loadcase(SAMPLE_DICT,CLUSTER,HH) then
    WEIGHT = SAMPLE_WEIGHT;
endif;
See also: Retrieve Function, WriteCase Function

Example from our Cleaning Programme,

PROC A0

//;...........................

flag=0;

BLOCKID=A0;

//errmsg ("blk id= %d A0 =%d ",BLOCKID,A0);

flag=loadcase(sheet2_dict,BLOCKID);
if flag=0 then

errmsg('MRCB Number(A0) Invalid. [ Data file(A0) = %05d ] ',BLOCKID);

endif;

cc=0;

if flag=1 then

if Month<>month1 then

errmsg('MONTH Invalid. [ A0 = %05d ] [ Data file(MONTH) = %02d ] ***** [ Sample File(MONTH)


= %02d ] ',A0,MONTH,MONTH1);

else

cc=cc+1;

endif;

endif;

if flag=1 then

if SECTOR<>SECTOR1 then

errmsg('SECTOR Invalid. [ A0 = %05d ] [ Data file(SECTOR) = %02d ] ***** [ Sample File(SECTOR)


= %02d ] ',A0,SECTOR,SECTOR1);

else

cc=cc+1;

endif;

endif;

if flag=1 then

if DISTRICT<>DISTRICT1 then

errmsg('DISTRICT Invalid. [ A0 = %05d ] [ Data file(DISTRICT) = %02d ] ***** [ Sample


File(DISTRICT) = %02d ] ',A0,DISTRICT,DISTRICT1);

else

cc=cc+1;

endif;
endif;

if flag=1 then

if DS<>DSCODE1 then

errmsg('DS Invalid. [ A0 = %05d ] [ Data file(DS) = %02d ] ***** [ Sample File(DS) = %02d ]
',A0,DS,DSCODE1);

else

cc=cc+1;

endif;

endif;

if flag=1 then

if PSU<>PSU1 then

errmsg('PSU Invalid. [ A0 = %05d ] [ Data file(PSU) = %02d ] ***** [ Sample File(PSU) = %02d ]
',A0,PSU,PSU1);

else

cc=cc+1;

endif;

endif;

// if cc=5 then

// errmsg('All IDENTIFICATION Fields are matching with the SAMPLE FILE.......');

//

// endif;

You might also like