03-16-2018 11:21 AM
03-16-2018 07:50 AM
The second data statement begins a new data step, so the do in the old one has no matching end. What are you trying to do?
03-16-2018 10:10 AM
The basic step would be
data nobs; set nobs_1 nobs_2 ; keep Nobsused; run;
If you have an arbitrary number of datasets, use
set nobs_1-nobs_&n. ;
if your number of datasets is stored in macro variable n.
03-16-2018 10:50 AM
03-16-2018 10:59 AM
What is NObsUsed?
I'm trying to figure out do-loops with a simple example. I have two datasets: nobs_1 and nobs_2. I would like to keep Nobsused in both datasets without merging the two datasets.
I am going to have about 16 different datasets that I need to modify. I need to keep them separately and run a code through them one-by-one.
03-16-2018 11:12 AM
I'm not a fan of twenty questions. Please explain your process in detail.
The approach you're currently trying doesn't make sense for any process.
03-16-2018 11:21 AM
03-16-2018 11:26 AM
03-16-2018 11:38 AM
If you state what you're trying to achieve we can recommend the best method.
For example, PROC DATASETS is more efficient to modify data sets to drop/keep variables that multiple data steps. If you take the approach used in other programming languages and try and apply them to another language, you miss learning how to efficiently use the new language.
Or that you can easily create a view with just the one variable that only gets created when called.
Thanks for your help. My intention was not to waste your time. I have been looking at do-loop examples and that is how I came up with the code above. My intuition comes from STATA, where it is possible to loop over different datasets and modify them without merging them. I now understand that that is not possible in SAS and that I need to write a macro to do that. I will try that and see how I do.
Thanks for your time.
Need further help from the community? Please ask a new question.