I have one sas dataset so want to check of that value and column_position not exist then add that obs in dataset else if value of column is not exist and column_position is same then replace that col_position (for example at 15th row there is one observation so now I want to add new value to 15th row then original 15th row goes to 16th obs , 16th obs goes to 17th...etc (n+1 r lag function not sure) I am trying this, but not working properly, please help me data test;
input value $ data_type $ length col_pos;
datalines;
harry varchar 100 1
henry number 100 2
homry varchar 100 3
;
%macro add_column(value,data_type,length,col_pos);
data _null_;
set test;
if value="&value" then call symput('col_name',1)
else call symput('col_name',2)
if col_pos="&col_pos" then call symput ('col_pos',1)
else call symput('col_pos,2)
run;
if &col_name=2 and &col_pos=2 then;
%do;
data test;
set test;
value="&value";
data_type="&data_type";
length="&length";
col_pos="&col_pos";
output;
run;
%end;
%mend;
%add_column(alex,varchar,100,4); Suppose if value changed and col_pos same For example, I need to replace 2nd col_pos and 2nd col_pos from test dataset above should go to 3rd %add_column(joe,varchar,100,2); if &col_name=2(as value is different) and &col_pos=1(col_pos is same i.e 2) then; (I am trying to write this but didn't worked) '2' col_pos is same Please help me with this
... View more