Hi @teelov
I think it might be a good idea to lay the coding aside and use your weekend to work on a data model. You are probably not reading these files just for fun, but because you need data for analysis and reporting, and you need to consider selection and organisation of data to fulfill these needs.
The data in your files represent objects in the real world and events concerning these objects, but the data has a structure, where information about these objects and events is atomized an organized in flows, groups and items. In order to analyse data, you need to "recreate" the objects and events in SAS data sets, where each object or event is a record with relevant describing attributes and keys to hold it all together.
It is not a simple task to make a good SAS data model, because it is necessary to understand data, to know what is behind flows, groups and items, but I know from long experience that it makes the coding much easier to have a well-defined result and a precise description of the mapping between file records and output observations/variables. So I strongly advise you to take a break from the coding and get a helicopter perspective on the whole process.
I whish you a good weekend
Erik
@teelov wrote:
ALSO, the other thing i just noticed is. the on the weblink i provided above, the "Flow Structure" as it appears on the web, is EXACTLY the order they appear in the file.
so the file spec cannot be sorted, unless we create a counter for the variable ordering
You may be misunderstanding how a data step reads the data to be worrying about this. The order of the code as generated for the GROUP variables in the SELECT has no actual bearing on the file as read. The code tests the current line of the file and reads that line only using the rules you have provided using the variable and informat.
You may have to provide a very concrete explicit example where the control data set order actually affects the execution.
It is extremely likely, given your comment about "two rows" that you have not provided complete information about the structure of your data.
Note that you can NEST instructions inside a select /when such as
Select (value);
when ('abc') do;
input var :3.;
if var < 5 then <do something>;
else <do something else>;
end;
In the context of this problem you likely have conditional rules involving reading. But if "two lines" of the data are supposed to be read conditionally as part of the same observation then the rules for identifying such have to be available somewhere before coding can be attempted.
I have made ample progress with this, but as most of you have pointed out understanding the data and how the hierarchy works is paramount.
here is a file spec for what we are calling a flow 2,the top of the spreadsheet is the raw code,the sas output is my current codes output. the blue lines are the desired output.
i've attached a spreadsheet with the input data and current output and desired output. where i'm getting stuck is when there are multiple rows within a given group (group being MPAN_Core)
FAILING dealing with this in one pass, i could split the dataset per group, but in production i've been told there cold be over 3000 separate groupings with multiple rows
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.