Hi..
ID | NAME | MARKS |
100 | SANJEEV | 23 |
101 | SRINATH | 25 |
102 | SRIHARI | 28 |
i want to add another row to the above data by using data step ...
Thanks in Advance....
(DATA AFTER ADDING THE ROW)
ID | NAME | MARKS |
---|---|---|
100 | SANJEEV | 23 |
101 | SRIHARI | 25 |
102 | SRINATH | 28 |
103 | SRIKANTH | 30 |
How about:
data have;
input ID$ NAME $ MARKS ;
cards;
100 SANJEEV 23
101 SRINATH 25
102 SRIHARI 28
;
data want;
length name $ 8;
set have end=eof;
output;
if eof then do;
id='103';
name='SRIKANTH';
marks=30;
output;
end;
run;
proc print;run;
Obs name ID MARKS
1 SANJEEV 100 23
2 SRINATH 101 25
3 SRIHARI 102 28
4 SRIKANTH 103 30
Linlin
How about:
data have;
input ID$ NAME $ MARKS ;
cards;
100 SANJEEV 23
101 SRINATH 25
102 SRIHARI 28
;
data want;
length name $ 8;
set have end=eof;
output;
if eof then do;
id='103';
name='SRIKANTH';
marks=30;
output;
end;
run;
proc print;run;
Obs name ID MARKS
1 SANJEEV 100 23
2 SRINATH 101 25
3 SRIHARI 102 28
4 SRIKANTH 103 30
Linlin
What if I want to add a row before first row in the above sample data?
Also if I sort it by Names and then want to imput a row before first row, how can it be done?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.