A SAS macro to split a dataset (.sas7bdat) into datasets where each resultant dataset contains exactly one column of the original data
data a; | |
do i = 1 to 10000; | |
b = i; | |
output; | |
end; | |
run; | |
%include "path/to/split_into_columns.sas"; | |
libname outlib "path/to/output/dataset/"; | |
%split_into_columns(a, outlib); |
%macro split_into_columns(ds, outlib); | |
proc contents data = &ds. out = contents noprint; | |
run; | |
data _null_; | |
set contents nobs = nn; | |
if _n_ = 1 then do; | |
call execute("data "); | |
end; | |
call execute(cat("&outlib..",cats(name),"(keep=",cats(name),")")); | |
if _n_ = nn then do; | |
call execute(";set &ds.;"); | |
call execute("run;"); | |
end; | |
run; | |
%mend split_into_columns; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment