How to insert data in speicfic observation(nth observation) in a dataset.?
Hi ...
Do you mean you want to add a row to a dataset after a specific observation???
If yes...Here is the way..
data test;
input id name$;
cards;
100 aaa
101 bbb
103 ddd
;
run;
Now i want to add a row after 2nd observation.
data test1;
set test;output;
if _n_=2 then do;
id=102;
name="ccc";
output;
end;
run;
proc print;
run;
Thanks&Regards..
Sanjeev.K
Hi ...
Do you mean you want to add a row to a dataset after a specific observation???
If yes...Here is the way..
data test;
input id name$;
cards;
100 aaa
101 bbb
103 ddd
;
run;
Now i want to add a row after 2nd observation.
data test1;
set test;output;
if _n_=2 then do;
id=102;
name="ccc";
output;
end;
run;
proc print;
run;
Thanks&Regards..
Sanjeev.K
Thanks a lot.I need that..
Nope..
please mark my answer as a correct answer..
Thanks..
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 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.