BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jinson
Calcite | Level 5

​i have fixed length file which has 5 segments and each segment in turn has 20 columns each for 1000 records.

i want to group  all segments together and do maupulation and then assign them back to the records they belong.

but there is no primary key for combining the segments back to their respective record and hence wnt to make a common id for all the segments belonging to each individual record

 

i.e want to create something like this so that i can take each segment convert the fixed length to columns and then assign each segment to their respective record based on the record id.

 

record       
1address segment     
v1v2v3v4v5v6
borrower segmrnt     
b1b2b3b4
demog segment     
2address segment     
v1v2v3v4v5v6
borrower segmrnt     
b1b2b3b4
demog segment     
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Assuming in your actual data file each record format HD, BS, AS etc. occur on a single line then something like this skeleton program may help.

 

data want;
   infile "your file" dlm='|' lrecl=32000;
   informat block $2.;
   /*informats to describe other variables to be read go here*/
   input block @;
   /* each input statement below should read the variables
      for that block
   */
   Select (block);
      when ('AS')
         input ASvar1 ASvar2 ASvar3 ;
      when ('BS')
         input bsvar1 bsvar2 bsvar3 ;
      when ('CS')
         input CSvar1 CSvar2 CSvar3 ;
      when ('HD')
         input HDvar1 HDvar2 HDvar3 ;
      when ('RS')
         input RSvar1 RSvar2 RSvar3 ;
     otherwise;
   end;
run;

You would have to supply the variable names and attributes from some documentation.

 

View solution in original post

4 REPLIES 4
Jinson
Calcite | Level 5

kindly find attached the sample data.

here HD BS AS RS and CS represents the 5 segments and data corresponding to them are the different fields in fixed length.

this is an example of only 1 record

Kurt_Bremser
Super User

So it looks that you have groups of records with different record types, recognizable by the value in the first 2-character column.

Each block starts with a 'BS' and ends with a 'CD'.

Can you supply the structure for the BS, AS, RS, CR, GS, SS and CD lines? And how you expect that to end up in a SAS dataset or in a group of datasets?

ballardw
Super User

Assuming in your actual data file each record format HD, BS, AS etc. occur on a single line then something like this skeleton program may help.

 

data want;
   infile "your file" dlm='|' lrecl=32000;
   informat block $2.;
   /*informats to describe other variables to be read go here*/
   input block @;
   /* each input statement below should read the variables
      for that block
   */
   Select (block);
      when ('AS')
         input ASvar1 ASvar2 ASvar3 ;
      when ('BS')
         input bsvar1 bsvar2 bsvar3 ;
      when ('CS')
         input CSvar1 CSvar2 CSvar3 ;
      when ('HD')
         input HDvar1 HDvar2 HDvar3 ;
      when ('RS')
         input RSvar1 RSvar2 RSvar3 ;
     otherwise;
   end;
run;

You would have to supply the variable names and attributes from some documentation.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1485 views
  • 1 like
  • 3 in conversation