BookmarkSubscribeRSS Feed
PravinMishra
Quartz | Level 8

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

4 REPLIES 4
Reeza
Super User

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.

PravinMishra
Quartz | Level 8

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

Reeza
Super User

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.

Haikuo
Onyx | Level 15

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2681 views
  • 0 likes
  • 3 in conversation