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
Generate a report
Re: Generate a report
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:
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.
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.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;
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.