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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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