Hi!
One question 😃 I have imported a data set in SAS. But now i want to insert a new column. I want this column to be about time. I want this column to be the first one. Lets say it start at 01/04/1997 12:00:00 and i want it to end at a specific date feks 03/07/1998 13:45:42, the freqency is per second... How can i code this ?i want to column to be indempendt of the data set 😃
Thx in advance 😃
Would this be what you are after:
data want;
do _n_=0 by 1 until (last);
set have end=last;
format time datetime22.;
if time < input('03/07/1998 13:45:42',anydtdtm21.) then time=intnx('second',input('01/04/1997 12:00:00',anydtdtm21.), _n_);
output;
end;
if last then do;
call symputx('time',time);
call missing (of _all_);
do _n_=1 by 1 while (time < input('03/07/1998 13:45:42',anydtdtm21.));
time=intnx('second',symget('time'), _n_);
output;
end;
end;
stop;
run;
Haikuo
To be honest that is way to complicated for me to understand :smileysilly:
Let me make an ex for you 😃
Example 1 (Orginaldata set):
Time Bid Ask
1/1/2013 12:00:00 1 1
1/1/2013 12:00:02 3 3
1/1/2013 12:00:06 1 2
1/1/2013 12:00:20 5 4
Example 2 (What i want):
Time 2 Time Bid Ask
1/1/2013 12:00:00 1/1/2013 12:00:00 1 1
1/1/2013 12:00:01 1/1/2013 12:00:02 3 3
1/1/2013 12:00:02 1/1/2013 12:00:06 1 2
1/1/2013 12:00:03 1/1/2013 12:00:20 5 4
1/1/2013 12:00:04
1/1/2013 12:00:05
.
.
.
1/1/2013 12:00:20
Hope you understand that i am very new to SAS 😃
Thx Hai Kuo
OK.
data have; input Time & anydtdtm20. Bid Ask ; format time datetime.; cards; 1/1/2013 12:00:00 1 1 1/1/2013 12:00:02 3 3 1/1/2013 12:00:06 1 2 1/1/2013 12:00:20 5 4 ; run; proc summary data=have; var time; output out=m max=_max min=_min; run; data temp; set m; do time2=_min to _max; output; end; format time2 datetime.; keep time2; run; data want; merge temp have; run;
Ksharp
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 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.