Just add some details about my question. I have monthly time-series data. And I want to predict forward 3 months. So there are some overlapping periods when running cross-validation. For example, if Jan and Feb are in the training set and March in the testing set, the model might know what is likely to happen when using the training set due to the overlapped periods. Currently, I run sampling before building the tree model and assign group id for cross-validation. For example, assign Jan, Feb, and Mar as group 1 and Jun and Jul as group 2. Pass the group ID to the tree model function. I implement it in R. Not sure how SAS can do it.
... View more
I'd like to build a tree model with cross-validation. I'd like to assign observations to different cross-validation groups by myself instead of random sampling. I am not sure how SAS can do this. It would be helpful if anybody can share some example SAS code. Many thanks in advance
... View more
Thank you for your code. Is it possible we can dynamically deal with the group? In my real code, the dataset is grouped by date. It expands over time.
... View more
Thank you for your suggestion. Can you help to write a sample code? I am an R user for several years. But still new to SAS. In my real code, there are thousands of groups. Wondered whether we can do the grouping calculation efficiently.
... View more
Many thanks. It is exactly what I wanted. Can I have the last request? How can I calculate N by group? For example, the test dataset has a group column. I want to count the number of the odd numbers by the group. Then set the two subgroups with the different increments. Appreciate your help. data test;
do i=1 to 10 by 1;
j=i+1;
if j<=5 then
group = 0;
else
group = 1;
start_range=0.5;
end_range=1;
output;
end;
run;
... View more
Yep, 2 steps. Also is it possible we can do it with the dynamic range defined in the columns like column start_range and end_range as below? data test;
do i=1 to 10 by 1;
j=i+1;
start_range=0.5;
end_range=1;
output;
end;
run;
... View more
Thank you for your help. It is great! Have a further question. Since we know there are five odd numbers, we set 1/5 as increment. How can we have a dynamic method to set the increment.
... View more
Hi, I'd like to search a column in a dataset based on some conditions. Then replace them with a sequence with range [0,1] and 1/n as increment (n is the number of data found based on the condition). For example, search odd numbers in the column j in the Test dataset below. Then replace '3, 5, 7, 9, 11' with '0.2, 0.4, 0.6, 0.8, 0.1'. data test;
do i=1 to 10 by 1;
j=i+1;
output;
end;
run; Many thanks in advance
... View more