BookmarkSubscribeRSS Feed
teelov
Quartz | Level 8
thanks very much, i will take today and some time over the weekend to see if i can get this to work. very happy for your contribution.

One thing i found this morning is you can get duplicate groups, with different values. which tell me that's a new row of data as the field names are the same but the values are different. this could be a 2 rate electric meter.

also i have to get the fields names to a SAS Standard, and as you can have the same field name in a file two or three times, its still only unique to that group (unless above statement is true)

thanks again
teelov
Quartz | Level 8
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
ErikLund_Jensen
Rhodochrosite | Level 12

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
Quartz | Level 8
ErikLund_Jensen, that is some of the best advice i've ever had on this site.

a very good mature way of looking at it, and you are right, at times, you can be a bit too close the problem and dont get the full picture

my issue is that i'm not an expert in this data, and i decided to get some traction going as there wasn't anyone will to take on this part of the project, who had the time.

I will digest what you have said and look more into how the data and events interaction with out main data model, and go from there.

thank you.
ballardw
Super User

@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.

teelov
Quartz | Level 8

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

 

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
  • 20 replies
  • 4701 views
  • 6 likes
  • 5 in conversation