Help using Base SAS procedures

Import from txt files, aggregate & manipulate EG9.5

Reply
Occasional Contributor
Posts: 8

Import from txt files, aggregate & manipulate EG9.5

I have data in text files that I need to input into sas tables.

The data is in text files like:

File_1978.txt

File_1979

File_1980

.

.

.

File_2014

I'd like to import them into a single sas table with an extra column "File_Year"

This is the import so far, but I'm having trouble concatenating the files on the fly, and adding the "File_Year"  Column.

Also, can I import values to char & int alternatively using a single input function?

Thanks!

%Macro ImportKQ (StartYr=, EndYr=, Qtr=);

%do Yr = &StartYr %to &EndYr;

     data KQ_IN.tbl_KQ6597B_&Yr&&qtr;           

           infile "C:\KQ6597B_&&Yr.&&qtr..txt" pad LRECL=193;          

                input

                     @1 Claim_No $14.

                     @15 CLID $9.

                     @26 State $2.

                     @28 Company $4.

                     @34 Coverage $3.

                     @37 Threshold $4.

                     @45 Loss_Month $2.

                     @48  Loss_Year $2.

                     @54  Policy_Month $2.

                     @57 Policy_Year $2.

                     @59 Retention_String $13.

                     @72 Paid_String $16.

                     @88 OS_String $16.

                     @104 Inc_String $16.

                     @120 SalSub_String $16.

                     @136 DCC_ALAE_String $16.

                     @152 AO_ALAE_String $16.

                     @169 CWP_CNT $5.

                     @174 CNP_CNT $5.

                     @179 OPN_CNT $5.

                     @184 REO_CNT $5.

                     @189 RPT_CNT $5.

                     ;

     run;

%end;

%Mend;

Ask a Question
Discussion stats
  • 0 replies
  • 139 views
  • 0 likes
  • 1 in conversation