Hi,
I have a data set:
LEVEL
4
5
23
64
3
4
I Need:
TIME LEVEL
1 4
2 5
3 23
4 64
5 3
6 4
How do i read in the "time" variable that iterates by one with each "level" observation?
Thanks in Advance!
There will be many ways to do that, the simplest way that I can think of:
/*data step*/
data have;
input LEVEL;
cards;
4
5
23
64
3
4
;
data want;
time=_n_;
set have;
run;
/*Proc SQL*/
proc sql;
select monotonic() as time, * from have;
quit;
Haikuo
There will be many ways to do that, the simplest way that I can think of:
/*data step*/
data have;
input LEVEL;
cards;
4
5
23
64
3
4
;
data want;
time=_n_;
set have;
run;
/*Proc SQL*/
proc sql;
select monotonic() as time, * from have;
quit;
Haikuo
Thanks Haikuo. That did it!
I prefer to ODS.
ods _all_ close; ods output sql_results=want; proc sql number; select * from sashelp.class; quit; ods listing;
Ksharp
Hi Ksharp,
what is the advantage to use ODS?
Thanks - Linlin
Linlin,
I think what Ksharp mean is that he prefer ODS to monotonic(), not data step. This has be discussed before, and Ksharp was involved. The main reason is that monotonic() is not officially supported by SAS.
Haikuo
Thank you Haikuo. - Linlin
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.