BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Barite | Level 11

Hi,

I have a big file and want to split it into different smaller file with the same record and fewer column each file.

In the below sample, I will split have into b and c file.

My issue is that I want to delete the columns already used so the have file becomes smaller after each round.

Of course I can do something like " data have; set have; drop..." but it takes time to run that data step.

 

Thank you.

 


data have;
input x b1 b11 b2 b22;
datalines;
1 5 10 20 1
2 5 1 2 2
3 50 100 200 3
;run;

%macro split_data (rr=);
data data_&rr ; set have;
keep x b&rr.: ;run; 
%mend;
%split_data (rr=1);
%split_data (rr=2);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Why not do it all in one data step? e.g.,

 

data have;
input x b1 b11 b2 b22;
datalines;
1 5 10 20 1
2 5 1 2 2
3 50 100 200 3
;
run;

data data1 (keep=x b1--b11)
         data2 (keep=x b2--b22);
  set have;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

3 REPLIES 3
Reeza
Super User

If you're splitting your table via columns you may as well set up a fact/dim table structure using a star or snowflake schema. 

If thats an option. 

 

What makes your file 'big'?

art297
Opal | Level 21

Why not do it all in one data step? e.g.,

 

data have;
input x b1 b11 b2 b22;
datalines;
1 5 10 20 1
2 5 1 2 2
3 50 100 200 3
;
run;

data data1 (keep=x b1--b11)
         data2 (keep=x b2--b22);
  set have;
run;

Art, CEO, AnalystFinder.com

 

hhchenfx
Barite | Level 11
Perfect, Art297.
The combine all in 1 data step save a lot of time.
HHC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 760 views
  • 1 like
  • 3 in conversation