Page 1 of 1

Generate a report

Posted: April 11th, 2020, 5:00 am
by btri Arjun
Dear team,

How can we generate a "population report" if the data file is associated with EA areas ie E001.csdb, E002.csdb and so on. The example under CSPro example folder ("Labor Force Survey"), which is associated with main data file only.

Thank you.

Warm,
-Arjun

Re: Generate a report

Posted: April 13th, 2020, 7:23 am
by josh
Instead of the single forcase loop you need a nested loop where the outer loop iterates over the different files and inside that loop you have the forcase loop to loop over the cases in the file. If all your data files are in the same directory you can use dirlist() to get the list of directories. Something like this:
list dataFiles;
dirlist(dataFiles, pathname(application) + "data/EA*.csdb");
do numeric ctr = 1 while ctr <= dataFiles.length()
     
setfile(HOUSEHOLD_DICT, dataFiles(ctr));
     
forcase HOUSEHOLD_DICT do
       
male = male + count(HOUSEHOLD_DICT.DEM_REC where SEX = 1);
        female = female +
count(HOUSEHOLD_DICT.DEM_REC where MSEX = 2);
     
endfor;
enddo;
Another option is to use fileconcat() to combine all your data files into a single file and then use that file for the report.

Personally, I prefer to just a single data file rather than having multiple data files. It makes a lot of things simpler, not just reporting.