BookmarkSubscribeRSS Feed
yjalilik
Calcite | Level 5

Hi!

I am running computer simulations and recording the values of a variable over time. I need to find out the when the variable reaches a predefined value for the first time and store it for further analysis. Can this be done in SAS? Also is there a procedure to calculate autocorrelation of a time series for a specific period of time (e.g. t=60 to t=200)?

 

My data will look like something like this:

time               variable

1                    10

2                    12

3                     15

4                     35

5                     48

6                     60

7                     87

8                     120

and I need to find out at what time variable becomes greater than or equal to 35. The output of the code should be t=4.

 

Thank you.

 

 

 

1 REPLY 1
slacey
Obsidian | Level 7

For the getting time something like this will work. The idea is we take advantage of the implicit loop in the SAS datastep and once it hits our threshold (here set to 35), it outputs that time value into a macro variable called tval and then stops the datastep.

 

data ds1;
	input time var;

datalines;
1     10
2     12
3     15
4     35
5     48
6     60
7     87
8     120
;
run;

proc sort data=ds1; by time; run;

data _NULL_;
	set ds1;

	if var >= 35 then do;
		call symput("tval",strip(put(time,3.)));
		stop;
	end;
run;

%put &tval;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 639 views
  • 3 likes
  • 2 in conversation