Hi,
I have a table called employee.Which have 10 different column or variable.I want to divide the table on the basis of column means 3 col or variable in each table.
code should handel if the col or variable number increased by 1000+.
Appreciate your suggestions.
Thanks
Your question is unclear. For starters:
What do you mean by divide?
How did you come up with 3?
10 is not equally divisible by 3, what happens to the remainder?
Please post sample data/output and/or more details.
you can divide the table vertically.I know it's not equally divisible. that's why I have put 3 as a number so that if what ever the column remain it ges to the last table
for ex below varidable or column are there
Last_name first_name Salary Address Hire_date Start_date End_date Account minsal maxsal
so Table1 will have
Last_name first_name Salary
Table 2
Address Hire_date Start_date
Table 3
End_date Account minsal
Table4
maxsal
let me know if I can able to explain you
Can I ask why you want to do this? You would have to keep a KEY variable across all datasets otherwise they're not useable together anymore.
If you are separating it's usually separating into a star/snowflake schema and fact table.
This macro should be flexible to meet your needs.
%MACRO SPLIT (
SIZE=3
,LIB=sashelp
,MEM=cars
,TARGET=cars
,LEN=200
);
%LOCAL I;
data _null_;
LENGTH VAR $ &LEN.;
do i=1 to &size until (last);
set sashelp.vcolumn (where=(LIBNAME="%upcase(&lib)" AND MEMNAME="%upcase(&mem)")) end=last;
VAR=CATX(' ', VAR, NAME);
END;
CALL SYMPUTX(CATS('NAME', _N_),VAR);
IF LAST THEN CALL SYMPUTX('N', _N_);
RUN;
DATA
%DO I=1 %TO &N;
&TARGET&I.(KEEP=&&NAME&I.)
%END;
;
SET &LIB..&MEM.;
RUN;
QUIT;
%MEND;
%SPLIT (
SIZE=4
,LIB=sashelp
,MEM=column
,TARGET=col
,LEN=100
)
Good Luck,
Haikuo
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.