09-28-2015 02:50 PM
I have a heirarchcical delimited data set that I need to import. Data are comma delimited. The first vaobservation in the heirarchy is a line indicating the number of lines is as follows:
The first varialbe is the number of lines following the first line that are assigned to the group, the second is the number of cells or volumetric partitions in the group (variables x lines), third is the group name, and the last three give information concerning size (width, length, depth) of the group,
The next set of lines look like this with each line representing a specific cell at the location as specified by the first two numbers, followed by the number of depths and followed thereafter with measurments and each of thoses depths.
The data cotinue like this ...
until you reach the 132 specified in the first line at which point you find another line demarcating another group as for example
This pattern repeats for the entire file. There is no EOF marker I need to retain the group information for each line of data at least until I can sum the data up. But first I have import the data. Can anyone suggest example code?
09-29-2015 08:26 AM
Well, there's no simple solution there I am afraid. Personally I would not have accepted this for data in the first place. What I would suggest is this:
1) Import the datafile using a datastep + infile and read the whole string each time into one variable, call it string:
length string $2000;
input string $;
2) Next write a datastep which starts by blocking the data out into sections:
data inter (drop=num);
retain num block;
if _n_=1 then do;
if num < 0 then do;
Now you have an id for each group and can process each row of data out into your variables by using scan, header record is shown with the Y so you can pull that out as well.