I have below SAS
code
data original_data;
input var1 $ var2;
datalines;
A 12
B 19
C 23
D 40
;
run;
data original_data1;
set original_data;
do i = 1 to 4;
new_val = var2 + 44;
end;
run;
In the line do i = 1 to 4
I put 4 manually as the number of rows of original_data
, however I wonder how can I put that information dynamically based on the number of rows in given dataset (e.g. nrow()
function in R
)
Have you looked over this https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000173782.htm?
You can use set nobs.
set original_data nobs=num_rows;