Hello, I want to drop a variable in a dataset which came from a transpose.
The difficulty here is the number of variables to drop : it can change following the number of columns at the end of the transpose.
I've tried this :
data datasetname;
set datasetname;
array date[&Dimension_tbl.];
do i=1 to &Dimension_tbl.;
drop date{i};
end;
run;
I don't understand why it doesn't work. Of course, the &Dimension_tbl. is defined earlier.
Ok. Then you can use the logic by @LinusH or simply do
drop date:;
Which will drop all variables prefixed with 'date' .
A few things.
Ok. Then you can use the logic by @LinusH or simply do
drop date:;
Which will drop all variables prefixed with 'date' .
No, but you can use a variable range for this:
drop date1-date&Dimension_tbl.;
@LinusH wrote:
No, but you can use a variable range for this:
drop date1-date&Dimension_tbl.;
This is the better answer than use date: variable list. If you drop using the date prefix it might drop other variables that were not intended.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.