BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dipun
Calcite | Level 5

How to insert  data in speicfic observation(nth observation) in a dataset.?

1 ACCEPTED SOLUTION

Accepted Solutions
kuridisanjeev
Quartz | Level 8

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

View solution in original post

3 REPLIES 3
kuridisanjeev
Quartz | Level 8

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

dipun
Calcite | Level 5

Thanks a lot.I need that..

kuridisanjeev
Quartz | Level 8

Nope..

please mark my answer as a correct answer..

Thanks..

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 829 views
  • 1 like
  • 2 in conversation