Desktop productivity for business analysts and programmers

Divide the table on column

Reply
Contributor
Posts: 60

Divide the table on column

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

Super User
Posts: 18,997

Re: Divide the table on column

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.

Contributor
Posts: 60

Re: Divide the table on column

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

Super User
Posts: 18,997

Re: Divide the table on column

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.

Respected Advisor
Posts: 3,156

Re: Divide the table on column

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

Ask a Question
Discussion stats
  • 4 replies
  • 699 views
  • 0 likes
  • 3 in conversation