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

I would like to set 12 tables (this scope can change, f.e. it can be 36 tables from: 2017, 2018, and 2019 year), where one table has about 20 milions rows.

I thought about creating view (at this moment only for year 2019):

 

data tab01_1/ view=tab01_1;

set tab01_2019:;

run;

 

But then I cannot make any operations on the view. f.e. when I try make proc sort, I have an error:

proc sort data = tab01_1;

by id;

run;

ERROR: Cannot sort in place.

ERROR: Unable to create WORK.tab01_1.DATA because WORK.tab01_1.VIEW already exists

 

What is the best way to set tables? Can I uIse UNION operator instead of SET?

Or maybe hash tables will be a good option? How it should look like for so many tables and records?

After creating so big table can I make some operations on its then?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You cannot overwrite a view with a dataset with the same name. Just tell PROC SORT what dataset you want to write the sorted data into.

proc sort data = tab01_1 out=tab01_1_sorted;
  by id;
run;

Note that if the original datasets that the view is reading are already sorted you can preserve the order by adding the BY to the view definition and eliminate the need to make a copy into a sorted dataset.

data tab01_1/ view=tab01_1;
  set tab01_2019:;
  by id;
run;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

You cannot overwrite a view with a dataset with the same name. Just tell PROC SORT what dataset you want to write the sorted data into.

proc sort data = tab01_1 out=tab01_1_sorted;
  by id;
run;

Note that if the original datasets that the view is reading are already sorted you can preserve the order by adding the BY to the view definition and eliminate the need to make a copy into a sorted dataset.

data tab01_1/ view=tab01_1;
  set tab01_2019:;
  by id;
run;
Tom
Super User Tom
Super User

In general it is much easier to keep the data for all years in one dataset and then use WHERE statement when using it to limit to the range you want.  But whether that will work for you depends on how it is created and how it is used. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 584 views
  • 1 like
  • 2 in conversation