Dear Sir,
Do we have an option to export many similar structure file to the same "Export to" file so that ,all the files are merged when executing them in Spss or stat together , or example . I tried it but failed to get the desired result.
set behavior() export (SPSS,subItemOnly,ANSI);
For rec_occ in C_TRAINING_OF_TRAINERS_COURSE1 do
export to xrec03
rec_type ("99")
Case_id(UNIQUE_ID,Region,City,sub_city),COURSE_01, C_TRAINING_OF_TRAINERS_COURSE1;
Enddo;
For rec_occ in C_TRAINING_OF_TRAINERS_COURSE2 do
export to xrec03
rec_type ("99")
Case_id(UNIQUE_ID,Region,City,sub_city),COURSE_02, C_TRAINING_OF_TRAINERS_COURSE2;
Enddo;
batch export
Re: batch export
I am not sure I completely understand the requirements. But if the goal is to combine two multiple records (in the same dictionary) for export, using relations is the way to go.
Firstly you need to define how occurrences of the two records C_TRAINING_OF_TRAINERS_COURSE1 and C_TRAINING_OF_TRAINERS_COURSE2 relate to each other. That is done with an item that has the same value between the two records. For example if each occurrence in your records represents a trainer, then you would need two items something like TRAINER_ID1 in the first record and TRAINER_ID2 in the second record. So in your data if the value of say TRAINER_ID1(1) is equal to TRAINER_ID2(5), then this means C_TRAINING_OF_TRAINERS_COURSE1(1) and C_TRAINING_OF_TRAINERS_COURSE(5) are related by the trainer ID. In this case the declaration of a relation would look something like this:
Then TRAINING_COURSES can be used in your code as a "virtual" multiple record:
Hope this helps.
Alex
Firstly you need to define how occurrences of the two records C_TRAINING_OF_TRAINERS_COURSE1 and C_TRAINING_OF_TRAINERS_COURSE2 relate to each other. That is done with an item that has the same value between the two records. For example if each occurrence in your records represents a trainer, then you would need two items something like TRAINER_ID1 in the first record and TRAINER_ID2 in the second record. So in your data if the value of say TRAINER_ID1(1) is equal to TRAINER_ID2(5), then this means C_TRAINING_OF_TRAINERS_COURSE1(1) and C_TRAINING_OF_TRAINERS_COURSE(5) are related by the trainer ID. In this case the declaration of a relation would look something like this:
Code: Select all
PROC GLOBAL
relation TRAINING_COURSES C_TRAINING_OF_TRAINERS_COURSE1
to C_TRAINING_OF_TRAINERS_COURSE2 where TRAINER_ID1 = TRAINER_ID2;
Code: Select all
PROC YOUR_LEVEL
for rec_occ in relation TRAINING_COURSES do
export to xrec03
case_id(UNIQUE_ID,Region,City,sub_city),
COURSE_01, C_TRAINING_OF_TRAINERS_COURSE1,
COURSE_02, C_TRAINING_OF_TRAINERS_COURSE2;
enddo;
Alex
Re: batch export
Thank you very much , Alex . Your approach also helps me to collapse the data which was 18 to one file ,but i would like to merge vertically instead of horizontally like what you did, The variable introduced course_01,course_02 .. Course_18 is a variable used to differentiate when append the data together i,e. one file on top of the others at export.
Many thanks
Many thanks