Help using Base SAS procedures

Inserting new row into dataset

Reply
Regular Contributor
Posts: 229

Inserting new row into dataset

Hi,


Data X;
Input id$;
cards;
A
B
D
E
Run;

output:
A
B
C
D
E
F

now i want to insert C after B.with out splitting the dataset
Super Contributor
Posts: 259

Re: Inserting new row into dataset

Your problem can be solved by using IF- and OUTPUT-statement:
[pre]
data x;
set x;
output; /* (1) */
if id = 'B' then do;
id = 'C';
output;
end;
run;[/pre]
(1): Automatic output is disabled as soon as one output-statement is coded.
Contributor
Posts: 74

Re: Inserting new row into dataset

I dont think you can achieve that within one data-input-cards-... step for this purpose. use proc sql insert into and order. this should do both inserting and sorting in one step systematically.
Ask a Question
Discussion stats
  • 2 replies
  • 123 views
  • 0 likes
  • 3 in conversation