Generate a report

Other discussions about CSPro
Post Reply
btri Arjun
Posts: 37
Joined: August 17th, 2018, 6:09 am

Generate a report

Post 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
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Generate a report

Post 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.
Post Reply