DATA Step, Macro, Functions and more

Loading to teradata

Reply
New Contributor
Posts: 3

Loading to teradata

Hi Everyone,

 

I have multiple SAS data sets generated from different tables in a single folder. All the SAS datasets have a common column which is the week and along with the week are the variables of those particular tables. Now, I would want to load all these SAS datasets in a single Teradata table with one week column and all the variables from all the other tables into it. A code for this would be really helpful.

 

Please suggest a way for this.

 

Thankyou in advance! 

Super User
Posts: 9,612

Re: Loading to teradata

What is the relationship of these tables with regard to week? Does every table only have one row per week?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 3

Re: Loading to teradata

Posted in reply to KurtBremser

Every table has the same set of weeks. And every table has only one row per week.

Table A Table B Table C 
WeekVariable_1WeekVariable_2WeekVariable_3
6-Nov-1616-Nov-16a6-Nov-16g
13-Nov-16213-Nov-16b13-Nov-16h
20-Nov-16320-Nov-16c20-Nov-16j
27-Nov-16427-Nov-16d27-Nov-16k
4-Dec-1654-Dec-16e4-Dec-16l

 

The above mentioned tables have to be consolidated as below:

 

Final Result Set in Teradata Table
WeekVariable_1Variable_2Variable_3
6-Nov-161ag
13-Nov-162bh
20-Nov-163cj
27-Nov-164dk
4-Dec-165el

 

 

All these SAS Datasets(Variable_1,Variable_2 and so on) are available in a folder. There are around 500 datasets. How to select them all and consolidate and load to a Teradata table as mentioned above.

 

Super User
Posts: 9,612

Re: Loading to teradata

The basic step would look like:

data teradata.target;:
merge
  ds1
  ds2
  ....
  dsN
;
by week;
run;

which will put all variables side-by-side (week will appear only once, of course).

Depending on the name structure of your existing datasets, you will either have the option of using dataset lists (Mergin with Dataset Lists), or you might have to use a macro to insert the list of dataset names in the merge statement.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 3 replies
  • 128 views
  • 1 like
  • 2 in conversation