--- rleda/rleda.c 2003/12/12 19:08:17 1.2 +++ rleda/rleda.c 2005/02/08 17:10:08 1.3 @@ -1,9 +1,13 @@ -/* $Id: rleda.c,v 1.2 2003/12/12 19:08:17 brouard Exp $ +/* $Id: rleda.c,v 1.3 2005/02/08 17:10:08 brouard Exp $ $State: Exp $ $Log: rleda.c,v $ - Revision 1.2 2003/12/12 19:08:17 brouard - Les variables ne sont plus toutes écrites en ligne mais avec un retour - à la ligne toutes les 5 variables. + Revision 1.3 2005/02/08 17:10:08 brouard + Lit le fichier index deux fois pour n'avoir qu'un passage en SAS. + AJoute le proc contents des fichiers créés en fin de run; + + Revision 1.2 2003/12/12 19:08:17 brouard + Les variables ne sont plus toutes écrites en ligne mais avec un retour + à la ligne toutes les 5 variables. Revision 1.1.1.1 2003/12/12 18:53:44 brouard Import de rleda @@ -36,8 +40,8 @@ #define ODIRSEPARATOR '/' #endif -char version[]="rleda-0.9.1 Programme de lecture de fichiers d'index au format LEDA convertis de l'EBCDIC en ASCII "; -char fullversion[]="$Revision: 1.2 $ $Date: 2003/12/12 19:08:17 $"; +char version[]="rleda-0.9.2 Programme de lecture de fichiers d'index au format LEDA convertis de l'EBCDIC en ASCII "; +char fullversion[]="$Revision: 1.3 $ $Date: 2005/02/08 17:10:08 $"; char line[MAXLINE]; char title[MAXLINE],namevar[MAXLINE], namevara[MAXLINE]; @@ -45,7 +49,7 @@ char fileres[FILENAMELENGTH], filereso[F char filesas[FILENAMELENGTH]; /* SAS file */ char filelog[FILENAMELENGTH]; /* Log file */ -FILE *ficlog, *ficres, *ficpar, *ficparo, *ficparsas; +FILE *ficlog, *ficres, *ficdat, *ficreso, *ficsas; static unsigned char const ascii_to_ebcdic[] = @@ -231,34 +235,35 @@ void trzb(char *z, char *in) main(int argc, char *argv[]) { - int numlinepar=0; - long nobs, ncar,ncara, ncartes, nn, nvaris=0; + int numlinepar=0, ilect=0, firstpass=0; + long nobs=0, ncar=0,ncara=0, ncartes=0, nn=0, nvaris=0; long c; long d; long numlis, ntype; long n, pos; - int level, olevel; + int level, olevel, levelmax; char scar; char s; + char var1[4][10], varn[4][10]; - char pathtot[MAXLINE], path[MAXLINE], optionfile[FILENAMELENGTH], optionfilext[FILENAMEEXTLEN]; - char optionfilefiname[FILENAMELENGTH]; + char pathtot[MAXLINE], path[MAXLINE], indexfile[FILENAMELENGTH], indexfilext[FILENAMEEXTLEN]; + char indexfilefiname[FILENAMELENGTH]; numlinepar=0; if(argc <=1){ - printf("\nEntrez le nom du fichier index binaire : "); + printf("\nEntrez le nom du fichier index binaire (dtrirdex) : "); scanf("%s",pathtot); } else{ strcpy(pathtot,argv[1]); } - split(pathtot,path,optionfile,optionfilext,optionfilefiname); - printf("pathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); + split(pathtot,path,indexfile,indexfilext,indexfilefiname); + printf("pathtot=%s,\npath=%s,\nindexfile=%s \nindexfilext=%s \nindexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname); chdir(path); /* Log file */ - strcat(filelog, optionfilefiname); + strcat(filelog, indexfilefiname); strcat(filelog,".log"); /* */ if((ficlog=fopen(filelog,"w"))==NULL) { printf("Problem with logfile %s\n",filelog); @@ -269,215 +274,262 @@ main(int argc, char *argv[]) fprintf(ficlog,"\nEntrez le nom du fichier d'index: "); fprintf(ficlog,"pathtot=%s\n\ path=%s \n\ - optionfile=%s\n\ - optionfilext=%s\n\ - optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); + indexfile=%s\n\ + indexfilext=%s\n\ + indexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname); fflush(ficlog); - if((ficpar=fopen(optionfile,"rb"))==NULL) { - printf("Problem with optionfile %s\n",optionfile); - fprintf(ficlog,"Problem with optionfile %s\n",optionfile); - fflush(ficlog); - goto end; - } strcpy(filereso,"o"); - strcat(filereso,optionfilefiname); + strcat(filereso,indexfilefiname); strcat(filereso,".txt"); - if((ficparo=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */ + if((ficreso=fopen(filereso,"w"))==NULL) { /* opened on subdirectory */ printf("Problem with Output resultfile: %s\n", filereso); fprintf(ficlog,"Problem with Output resultfile: %s\n", filereso); fflush(ficlog); goto end; } - fprintf(ficparo,"Log filename:%s\n",filelog); - fprintf(ficparo,"\n%s\n%s",version,fullversion); - fprintf(ficparo,"\nEntrez le nom du fichier d'index: "); - fprintf(ficparo,"pathtot=%s\n\ + fprintf(ficreso,"Log filename:%s\n",filelog); + fprintf(ficreso,"\n%s\n%s",version,fullversion); + fprintf(ficreso,"\nEntrez le nom du fichier d'index: "); + fprintf(ficreso,"pathtot=%s\n\ path=%s \n\ - optionfile=%s\n\ - optionfilext=%s\n\ - optionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); - fflush(ficparo); + indexfile=%s\n\ + indexfilext=%s\n\ + indexfilefiname=%s\n",pathtot,path,indexfile,indexfilext,indexfilefiname); + fflush(ficreso); strcpy(filesas,"s"); - strcat(filesas,optionfilefiname); + strcat(filesas,indexfilefiname); strcat(filesas,".sas"); - if((ficparsas=fopen(filesas,"w"))==NULL) { /* opened on subdirectory */ - printf("Problem with Output resultfile: %s\n", filesas); - fprintf(ficlog,"Problem with Output resultfile: %s\n", filesas); - fflush(ficlog); - goto end; - } - fprintf(ficparsas,"*Sortie de rleda version %s *;\n* %s *;\n",version,fullversion); - fprintf(ficparsas,"libname %s \"%s\";\n",optionfilefiname,path); - fprintf(ficparsas,"filename a \"%s.dat\";\n",optionfilefiname ); - fprintf(ficparsas,"* Ci dessous a modifier *;\n"); - fprintf(ficparsas,"data %s.u?? (keep=??);\n",optionfilefiname); - fprintf(ficparsas,"infile a lrecl=500 ;\n"); - fprintf(ficparsas,"input id 1. @; retain numero 0;\n"); - fprintf(ficparsas,""); - fprintf(ficparsas,""); printf("Le nom du fichier de sortie est %s\n",filereso); printf("Le nom du fichier SAS de sortie est %s\n",filesas); - pos=9;nvaris=0 ; - level=0; - while((c=getc(ficpar)) != EOF){ - ungetc(c,ficpar); - ntype=0;for(n=0;n<2;n++){ c=getc(ficpar); ntype+=(n+(1-n)*256)*ascii_to_ebcdic[c];} - fprintf(ficlog,"ntype=%d ",ntype); -/* printf("ntype=%d ",ntype); */ - switch(ntype){ - case 11 : /* 11*/ - nobs=0; - for(n=0;n<2;n++){ - c=getc(ficpar); - d=(n+(1-n)*256)*ascii_to_ebcdic[c]; - nobs+=d; + for(ilect=1;ilect<=2;ilect++){ + pos=9;nvaris=0 ; + level=0; + printf("Lecture du fichier d index pour la %d fois\n",ilect); + if((ficdat=fopen(indexfile,"rb"))==NULL) { + printf("Problem with binary file %s\n",indexfile); + fprintf(ficlog,"Problem with binary file %s\n",indexfile); + fflush(ficlog); + goto end; + } + if(ilect==2){ + if((ficsas=fopen(filesas,"w"))==NULL) { /* opened on subdirectory */ + printf("Problem with Output resultfile: %s\n", filesas); + fprintf(ficlog,"Problem with Output resultfile: %s\n", filesas); + fflush(ficlog); + goto end; } - fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - printf(" %s\n", title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - break; - case 12: /* 12 */ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - printf(" %s\n", title); - ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<8;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - olevel=level; - level=title[0]-48; - printf(" Niveau = %d Colonnes 1 8 = %s\n",level,title); - fprintf(ficlog," Niveau = %d Colonnes 1 8 = %s\n",level,title); - fprintf(ficparo," Niveau = %d Colonnes 1 8 = %s\n",level,title); - if(level ==0) fprintf(ficparsas,"if id=%d then do;\n",level); - /* fprintf(ficparsas," input @9 "); */ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<2;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - break; - case 10: /* 10 = 142 ascii*/ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); - printf(" %s\n", title); - trzb(namevar,title); - ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); - ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); - printf(" %s %d\n",namevar,ncara); - fprintf(ficparo," %s %d\n",namevar,ncara); - ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); - break; - case 14: /* 14 */ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); - trzb(namevar,title); - printf("%d %20s ",level, namevar); - fprintf(ficparo,"%d %20s ",level, namevar); - fprintf(ficlog,"Variable \"%s\" \n",namevar); - ncartes=0;for(n=0;n<2;n++){ c=getc(ficpar); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - ncara=0;for(n=0;n<2;n++){ c=getc(ficpar); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); - printf(" %6d",ncara); /* Nombre de caractres */ - fprintf(ficparo," %6d",ncara); /* Nombre de caract res */ - ncar=0;for(n=0;n<2;n++){ c=getc(ficpar); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); - trzb(namevara,title); - printf("%10s ", namevara); /* Association */ - fprintf(ficparo,"%10s ", namevara); /* Association */ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<2;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"\"%s\"",title); - printf("%3s", title); /* Brute C ou Calcule R */ - fprintf(ficparo,"%3s", title); /* Brute C ou Calcul e R */ - if(strrchr(title,'C')!= 0 || strrchr(title,'G')!=0){ - if(level!=olevel){ - pos=9; - fprintf(ficparsas,";\n output %s.u%d;\n",optionfilefiname,olevel); - fprintf(ficparsas," end\n"); - if(level !=0) fprintf(ficparsas,";\n else if id=%d then do;\n",level); - fprintf(ficparsas," input @9 "); - olevel=level; + fprintf(ficsas,"*Sortie de rleda version %s *;\n* %s *;\n",version,fullversion); + fprintf(ficsas,"libname %s \"%s\";\n",indexfilefiname,path); + fprintf(ficsas,"filename a \"%s.dat\";\n",indexfilefiname ); + fprintf(ficsas,"* Ci dessous a modifier eventuellement *;\n"); + fprintf(ficsas,"data %s.%s0 (keep=ID)\n",indexfilefiname,indexfilefiname); + for(level=1; level <=levelmax; level++){ + fprintf(ficsas," %s.%s%d (keep=%s--%s)\n",indexfilefiname,indexfilefiname,level,var1[level],varn[level]); + } + fprintf(ficsas," ;\n"); + fprintf(ficsas," infile a lrecl=500 ;\n"); + fprintf(ficsas," input id 1. @; \n"); + fprintf(ficsas,""); + fprintf(ficsas,""); + } + while((c=getc(ficdat)) != EOF){ + ungetc(c,ficdat); + ntype=0;for(n=0;n<2;n++){ c=getc(ficdat); ntype+=(n+(1-n)*256)*ascii_to_ebcdic[c];} + fprintf(ficlog,"ntype=%d ",ntype); + /* printf("ntype=%d ",ntype); */ + switch(ntype){ + case 11 : /* 11*/ + nobs=0; + for(n=0;n<2;n++){ + c=getc(ficdat); + d=(n+(1-n)*256)*ascii_to_ebcdic[c]; + nobs+=d; } - printf(" %d-%d", pos, pos+(ncara-1)); - fprintf(ficparo," %d-%d", pos, pos+(ncara-1)); - for(n=0;n=5) { - fprintf(ficparsas,"\n ") ; - nvaris=0 ; + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<2;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"\"%s\" ",title); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + break; + case 10: /* 10 = 142 ascii*/ + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); + printf(" %s\n", title); + trzb(namevar,title); + ncartes=0;for(n=0;n<2;n++){ c=getc(ficdat); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); + ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); + printf(" %s %d\n",namevar,ncara); + fprintf(ficreso," %s %d\n",namevar,ncara); + ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); + break; + case 14: /* 14 */ + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); + trzb(namevar,title); + printf("%d %20s ", level, namevar); + fprintf(ficreso,"%d %20s ",level, namevar); + fprintf(ficlog,"Variable \"%s\" \n",namevar); + ncartes=0;for(n=0;n<2;n++){ c=getc(ficdat); ncartes+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncartes=%d ",ncartes); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + ncara=0;for(n=0;n<2;n++){ c=getc(ficdat); ncara+=(n+(1-n)*256)*ascii_to_ebcdic[c]; } fprintf(ficlog,"ncara=%d ",ncara); + printf(" %6d",ncara); /* Nombre de caractres */ + fprintf(ficreso," %6d",ncara); /* Nombre de caract res */ + ncar=0;for(n=0;n<2;n++){ c=getc(ficdat); ncar+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"ncar=%d ",ncar); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); + trzb(namevara,title); + printf("%10s ", namevara); /* Association */ + fprintf(ficreso,"%10s ", namevara); /* Association */ + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<2;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"\"%s\"",title); + printf("%3s", title); /* Brute C ou Calcule R */ + fprintf(ficreso,"%3s", title); /* Brute C ou Calcul e R */ + if(strrchr(title,'C')!= 0 || strrchr(title,'G')!=0){ + if(level!=olevel){ + pos=9; + firstpass=0; + if(ilect==2){ + fprintf(ficsas," ;\n output %s.%s%d;\n",indexfilefiname,indexfilefiname,olevel); + fprintf(ficsas," end\n"); + } + if(level !=0) + if(ilect==2){ + fprintf(ficsas," ;\n else if id=%d then do;\n",level); + } + if(ilect==2){ + fprintf(ficsas," input @9 "); + printf(" input @9 "); + } + if(ilect==1){ + levelmax=level; + } + olevel=level; + } + printf(" %d-%d", pos, pos+(ncara-1)); + fprintf(ficreso," %d-%d", pos, pos+(ncara-1)); + for(n=0;n=5) { + if(ilect==2){ + fprintf(ficsas,"\n ") ; + } + nvaris=0 ; + } } + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title); + trzb(namevar,title); + printf(" %10s\n", namevar); /* format */ + fprintf(ficreso," %10s", namevar); /* format */ + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + break; + default: fprintf(ficlog,"Warning ntype=%d cas non prvu, voir les fichiers sources",ntype); + nobs=0;for(n=0;n<2;n++){ c=getc(ficdat); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); + for(n=0;n<30;n++){ c=getc(ficdat); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); + printf(" %s\n", title); } - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title); - trzb(namevar,title); - printf(" %10s\n", namevar); /* format */ - fprintf(ficparo," %10s", namevar); /* format */ - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0';fprintf(ficlog,"%s ",title); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - break; - default: fprintf(ficlog,"Warning ntype=%d cas non prvu, voir les fichiers sources",ntype); - nobs=0;for(n=0;n<2;n++){ c=getc(ficpar); nobs+=(n+(1-n)*256)*ascii_to_ebcdic[c];} fprintf(ficlog,"nobs=%d ",nobs); - for(n=0;n<30;n++){ c=getc(ficpar); title[n]=c;} title[n]='\0'; fprintf(ficlog,"%s ",title); - printf(" %s\n", title); - } - n=0; - while((c=getc(ficpar)) !='\r'){ - nn= n % ncara; - title[nn]=c; - if(nn==ncara-1){ - title[nn+1]='\0'; - fprintf(ficlog," \"%s\"",title); - printf(" \"%s\"",title); - fprintf(ficparo," \"%s\"",title); - n=n+1; - }else{ - n=n+1; + n=0; + while((c=getc(ficdat)) !='\r'){ + if(ncara != 0) + nn= n % ncara; + else + nn=0; + title[nn]=c; + if(nn==ncara-1){ + title[nn+1]='\0'; + fprintf(ficlog," \"%s\"",title); + printf(" \"%s\"",title); + fprintf(ficreso," \"%s\"",title); + n=n+1; + }else{ + n=n+1; + } } - } - if(c=='\r') - if((c=getc(ficpar))=='\n'); - else ungetc(c,ficpar); - fprintf(ficlog,"\n"); - fprintf(ficparo,"\n"); - } - fprintf(ficparsas,";\n output %s.u%d;\n end;\n else input;\n run;",optionfilefiname,level); - fclose(ficparsas); + if(c=='\r') + if((c=getc(ficdat))=='\n'); + else ungetc(c,ficdat); + fprintf(ficlog,"\n"); + fprintf(ficreso,"\n"); + } /* End of read loop */ + fclose(ficdat); + } /* End loop ilect */ + + fprintf(ficsas," ;\n output %s.%s%d;\n end;\n else input;\nrun;\n",indexfilefiname,indexfilefiname,level); + for(level=0; level <=levelmax; level++){ + fprintf(ficsas,"proc contents data=%s.%s%d;run;\n",indexfilefiname,indexfilefiname,level); + } + fclose(ficsas); printf("Le nom du fichier de debug est %s\n",filelog); printf("Le nom du fichier du format de sortie est %s\n",filereso); printf("Le nom du fichier SAS de sortie est %s\n",filesas); - fclose(ficpar); - fclose(ficparo); + fclose(ficreso); fclose(ficlog); exit(0); end: