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 | ||||||
1 | address segment | |||||
v1 | v2 | v3 | v4 | v5 | v6 | |
borrower segmrnt | ||||||
b1 | b2 | b3 | b4 | |||
demog segment | ||||||
2 | address segment | |||||
v1 | v2 | v3 | v4 | v5 | v6 | |
borrower segmrnt | ||||||
b1 | b2 | b3 | b4 | |||
demog segment |
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.
Please post your example data in a data step, as described in https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... and https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce
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
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?
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.
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!
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.