BookmarkSubscribeRSS Feed
Solankiaxay234
Calcite | Level 5

Hello all,

I've 30 pressure values of 30 locations at the same timestamp hourly (see Image) 

Desire output is p1 and p2

If time is 60 min then take p2 as the next interval of hour of Pressure value and assign that particular row Pressure value as P1.

 

Note: time interval may be more than 1 hr from one station to another station then take the previous one station pressure value as P2.

 

1.jpg

 

 

 

 

 

 

 

 

2 REPLIES 2
ballardw
Super User

First thing, it is extremely hard to code against pictures and most of us do not have the time to attempt to enter your data by hand.

 

Second, I think you need to provide some details about exactly what " time is 60 min then take p2 as the next interval of hour of Pressure value and assign that particular row Pressure value as P1." means. Your shown values encompass a time from of exactly 1 SECOND. So there is no chance of telling what "60 min" means.

Such as indicate which specific value by time is meant for your examples and provide them in example data. When you have same values in a single variable for multiple records it is extremely hard to tell which specific record a given value comes from.

And is your "pressure" a text or character variable? Are P1,P2 etc supposed to be numeric?

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the <> icon or attached as text to show exactly what you have and that we can test code against.

Solankiaxay234
Calcite | Level 5

Hi sorry for the inconvenience,

 

I attached dummy data excel file.

I take 1st 300 observation

  • Here I've 30 station pressure values at the same timestamp. (Seq 1 to 30 takes as a Station Name sequentially).
  • Now take 2nd Observation of time 01Jun2010 0:01:00 and its 1st station is "first" and its corresponding pressure value is P1=32.
  • Now see the time variable, Take Sum of that time till 60 or more than 60, then see the corresponding row station is 6. So take that station's next Hour's value as a P2 (Here in our case 01Jun2010 1:01:00 seq no 6 that is station 6 Pressure value P2=40)
  • So for the 2nd Station pressure value is P1=32 and P2=40.
  • DateTimeSEQP01Travel_Time_MinuteP02
    01Jun2010 0:01:000137  
    01Jun2010 0:01:00023213.3715834940
  • This Scenario is like this when I stand at 1st station pressure value as p1 and I want to know after 60 min next station pressure value is P2. 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 786 views
  • 0 likes
  • 2 in conversation