I have a dataset with more than 100 variables and I want to change the length of two character vars .I thought of using SQL(by listing all the 100 vars,so that i can maintain the order of the vars in original dataset),but just want to know any other method I can use to change length and also maintain the order of variables in the dataset.
You can use variable lists. Let we have variables i, z, g, p and would like to change length of g then
i=1; z=15.; g="3."; p="14";
select name as lst into :lst separated " " from SASHELP.VCOLUMN
where LIBNAME="WORK" and MEMNAME="I"
length g $5;
You can also use proc datasets to modify the length of the variables. It will still maintain the order of the variables.
input name $ class $ dept $ designation $;
George IV computers Comp_dev
proc contents data =a;
retain class dept designation name;
proc datasets lib=work nolist;
format name $20.;
proc contents data =b;