SlideShare a Scribd company logo
1 of 27
CC-41-2017
Dictionary.coumns is your friend
while appending or moving data
Kiran Venna
Dataspace Inc.
Agenda
• Motivation
• Introduction
• Appending of wrong data
• Issue of longer column name length
• Difference in number of columns issue
• Conclusion
Motivation
• Column related issues
1. Data Integrity issues
2. Failed queries
Introduction
• Dictionary --- library which contains
metadata information about the session
• dictionary.dictionaries have all information
of metadata tables
Introduction Contd..
Member Name Data Set Label
CATALOGS Catalogs and catalog-specific information
CHECK_CONSTRAINTS Check constraints
COLUMNS Columns from every table
CONSTRAINT_COLUMN_USAGE Constraint column usage
CONSTRAINT_TABLE_USAGE Constraint table usage
DATAITEMS Information Map Data Items
proc sql;
select distinct memname,
memlabel
from dictionary.dictionaries;
quit;
Introduction contd..
proc sql;
describe table dictionary.columns;
quit;
Create table DICTIONARY.COLUMNS
(
libname char(8) label='Library Name',
memname char(32) label='Member Name',
memtype char(8) label='Member Type',
name char(32) label='Column Name',
type char(4) label='Column Type',
length num label='Column Length',
npos num label='Column Position',
varnum num label='Column Number in Table',
label char(256) label='Column Label',
format char(49) label='Column Format');
Appending of wrong data due to
column order issue with external
file
Reading external file
data WORK.PERSON;
INFILE "&filenm." firstobs=2 LRECL=10240 missover
dsd;
INPUT fname $ lname $ state $ imp ;
run ;
fname lname state imp
James Smith KY 200
Maria Rodriguez NY 300
External file in wrong column order
data WORK.PERSON;
INFILE "&filenm." firstobs=2 LRECL=10240 missover dsd;
INPUT fname $ lname $ state $ imp ;
run ;
When data is stored in external file as
fname imp lname state
Thomas 100 Miller NY
fname lname state imp
Thomas 100 Mi .
Appending wrong data
proc append base =PROD.PERSON
data =PERSON1;
run;
fname lname state imp
James Smith KY 200
Maria Rodriguez NY 300
Thomas 100 Mi .
Fixing column order issue
• 1st step – make a macrovariable of column
order of reference table/Production table
proc sql noprint;
select name into :standard separated by ','
from dictionary.columns
where upper(libname) = 'PROD'
and upper(memname) = 'PERSON';
quit;
Fixing column order –2nd step
options obs=1;
PROC IMPORT OUT= WORK.PERSON1 DATAFILE=
"/somelocation/person1.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
Fixing column order –2nd step Contd..
proc sql noprint;
select name into :test separated by ','
from dictionary.columns
where upper(libname) = 'WORK'
and upper(memname) = 'PERSON1';
quit;
Fixing column length –final step
%macro abc;
Proc options obs =max;
%if "&standard" = "&test "
%then %do;
DATA WORK.PERSON;
INFILE "&filenm." firstobs=2 LRECL=10240 missover dsd;
INFORMAT fname $6. lname : $9. state : $2. imp BEST32.
;
INPUT fname $ lname $ state $ imp ;
RUN;
Proc append;
Base = PROD.PERSON
Data = WORK.PERSON1;
Quit;
%end;
%else %do;
%put “Something is wrong please inform your manager”;
%mend abc;
Longer column length issue
when moving data from Hive to
Teradata by SAS
Issue when moving data from Hive to
Teradata
data teradb.shoppingmart;
set hivedb.shoppingmart;
run;
• ERROR: Variable
shoppingmartactivitymodification has been
defined as both character and numeric
Longer column name issue
• maximum column name length allowed in
hive (128), when compared to maximum
column name length allowed in SAS (32)
• shoppingmartactivitymodificationdatetime
(character variable)
shoppingmartactivitymodificationcustid
(numeric variable).
• After Truncation
shoppingmartactivitymodification.
Help from Dictionary.columns
• name and label of dictionary.columns
store name of DBMS table
• In dictionary.columns, maximum allowed
column name length is 32 and maximum
allowed column label length is 256.
• Column name of DBMS table is never
truncated in label
Help from Dictionary.columns contd..
proc sql;
select a.name, a.label
from dictionary.columns a
inner join dictionary.columns b
on a.memname = ' SHOPPINGMART'
and a.libname = 'HIVE_DB'
and a.name =b.name
and a.label ne b.label;
quit;
Solution to long column length issue
by PROC FEDSQL
proc fedsql;
create table teradb.SHOPPINGMART as
select * from hive_db.SHOPPINGMART
quit;
Difference in number of columns
while appending data from SAS to
Teradata
Failed Inserts
proc sql;
insert into TERADB.EMP
select * from SASDB.EMP;
quit;
• ERROR: Attempt to insert fewer columns
than specified after the INSERT table
name
Finding additional Columns
proc sql;
select * from dictionary.columns
where memname = "EMP"
and libname ='TERADB'
and varnum not in
(select varnum from
dictionary.columns
where memname = "EMP"
and upcase(libname) ='SASDB');
quit;
Solution to additional column length
issue –step 1
proc sql noprint;
select name into :columns separated by ',' from
dictionary.columns
where memname = "EMP"
and upcase(libname) ='TERADB'
and varnum in
(select varnum from
dictionary.columns
where memname = "EMP"
and libname ='SASDB');
Solution to additional column length
issue –final step
proc sql;
insert into TERADB.EMP(&columns)
select * from SASDB.EMP;
quit;
• There are many other ways this problem
can be solved
Conclusion
• Dictionary.columns are very helpful in
understanding columns of the tables
available in any library.
• Dictionary.columns will give metadata
information for columns of SAS tables
along with other RDBMS tables.
• Comparing columns between various
heterogeneous sources can be done with
help of Dictionary.columns.
Thanks
• Thanks for listening
• I would like to specially thank, Paul Kirk
Lafler for encouraging me to write papers.
• I would like to thank, Lakshmi Nadiya
Chintalapudi, Charannag Devarapalli ,
Sarika Elisetti, Anvesh Reddy Perati,
Srirama Reddy, Suryakiran Pothuraju for
helping me with proof reading and giving
their valuable suggestions.

More Related Content

What's hot (18)

005 foxpro
005 foxpro005 foxpro
005 foxpro
 
SQL
SQLSQL
SQL
 
SQL
SQLSQL
SQL
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )
 
Oracle naveen Sql
Oracle naveen   SqlOracle naveen   Sql
Oracle naveen Sql
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdf
 
SQL Queries - DDL Commands
SQL Queries - DDL CommandsSQL Queries - DDL Commands
SQL Queries - DDL Commands
 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
 
Structured Query Language(SQL)
Structured Query Language(SQL)Structured Query Language(SQL)
Structured Query Language(SQL)
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
NOTES ON "FOXPRO"
NOTES ON "FOXPRO" NOTES ON "FOXPRO"
NOTES ON "FOXPRO"
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 

Similar to Dictionary.coumns is your friend while appending or moving data

MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptDrRShaliniVISTAS
 
Obtain better data accuracy using reference tables
Obtain better data accuracy using reference tablesObtain better data accuracy using reference tables
Obtain better data accuracy using reference tablesKiran Venna
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL Rc Os
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial Jm Ramos
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standardsAlessandro Baratella
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql SyntaxReka
 
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015Alex Zaballa
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 

Similar to Dictionary.coumns is your friend while appending or moving data (20)

MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
Module 3
Module 3Module 3
Module 3
 
Obtain better data accuracy using reference tables
Obtain better data accuracy using reference tablesObtain better data accuracy using reference tables
Obtain better data accuracy using reference tables
 
Dbms sql-final
Dbms  sql-finalDbms  sql-final
Dbms sql-final
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
Sql
SqlSql
Sql
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standards
 
[PHPUGPH] PHP Roadshow - MySQL
[PHPUGPH] PHP Roadshow - MySQL[PHPUGPH] PHP Roadshow - MySQL
[PHPUGPH] PHP Roadshow - MySQL
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015Oracle Database 12c  New Features for Developers and DBAs - OTN TOUR LA 2015
Oracle Database 12c New Features for Developers and DBAs - OTN TOUR LA 2015
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Lab
LabLab
Lab
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 

Recently uploaded

1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证dq9vz1isj
 
MATERI MANAJEMEN OF PENYAKIT TETANUS.ppt
MATERI  MANAJEMEN OF PENYAKIT TETANUS.pptMATERI  MANAJEMEN OF PENYAKIT TETANUS.ppt
MATERI MANAJEMEN OF PENYAKIT TETANUS.pptRachmaGhifari
 
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...BabaJohn3
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsBrainSell Technologies
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...Amil baba
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证acoha1
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证zifhagzkk
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchersdarmandersingh4580
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证pwgnohujw
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token PredictionNABLAS株式会社
 
What is Insertion Sort. Its basic information
What is Insertion Sort. Its basic informationWhat is Insertion Sort. Its basic information
What is Insertion Sort. Its basic informationmuqadasqasim10
 
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证a8om7o51
 
Sensing the Future: Anomaly Detection and Event Prediction in Sensor Networks
Sensing the Future: Anomaly Detection and Event Prediction in Sensor NetworksSensing the Future: Anomaly Detection and Event Prediction in Sensor Networks
Sensing the Future: Anomaly Detection and Event Prediction in Sensor NetworksBoston Institute of Analytics
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...ssuserf63bd7
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunksgmuir1066
 
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...ssuserf63bd7
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样jk0tkvfv
 
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...yulianti213969
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives23050636
 

Recently uploaded (20)

1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
 
MATERI MANAJEMEN OF PENYAKIT TETANUS.ppt
MATERI  MANAJEMEN OF PENYAKIT TETANUS.pptMATERI  MANAJEMEN OF PENYAKIT TETANUS.ppt
MATERI MANAJEMEN OF PENYAKIT TETANUS.ppt
 
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
 
How to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data AnalyticsHow to Transform Clinical Trial Management with Advanced Data Analytics
How to Transform Clinical Trial Management with Advanced Data Analytics
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
 
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchers
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
What is Insertion Sort. Its basic information
What is Insertion Sort. Its basic informationWhat is Insertion Sort. Its basic information
What is Insertion Sort. Its basic information
 
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
如何办理加州大学伯克利分校毕业证(UCB毕业证)成绩单留信学历认证
 
Sensing the Future: Anomaly Detection and Event Prediction in Sensor Networks
Sensing the Future: Anomaly Detection and Event Prediction in Sensor NetworksSensing the Future: Anomaly Detection and Event Prediction in Sensor Networks
Sensing the Future: Anomaly Detection and Event Prediction in Sensor Networks
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
 
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
Data Visualization Exploring and Explaining with Data 1st Edition by Camm sol...
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单学位证留信学历认证原件一样
 
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
 

Dictionary.coumns is your friend while appending or moving data

  • 1. CC-41-2017 Dictionary.coumns is your friend while appending or moving data Kiran Venna Dataspace Inc.
  • 2. Agenda • Motivation • Introduction • Appending of wrong data • Issue of longer column name length • Difference in number of columns issue • Conclusion
  • 3. Motivation • Column related issues 1. Data Integrity issues 2. Failed queries
  • 4. Introduction • Dictionary --- library which contains metadata information about the session • dictionary.dictionaries have all information of metadata tables
  • 5. Introduction Contd.. Member Name Data Set Label CATALOGS Catalogs and catalog-specific information CHECK_CONSTRAINTS Check constraints COLUMNS Columns from every table CONSTRAINT_COLUMN_USAGE Constraint column usage CONSTRAINT_TABLE_USAGE Constraint table usage DATAITEMS Information Map Data Items proc sql; select distinct memname, memlabel from dictionary.dictionaries; quit;
  • 6. Introduction contd.. proc sql; describe table dictionary.columns; quit; Create table DICTIONARY.COLUMNS ( libname char(8) label='Library Name', memname char(32) label='Member Name', memtype char(8) label='Member Type', name char(32) label='Column Name', type char(4) label='Column Type', length num label='Column Length', npos num label='Column Position', varnum num label='Column Number in Table', label char(256) label='Column Label', format char(49) label='Column Format');
  • 7. Appending of wrong data due to column order issue with external file
  • 8. Reading external file data WORK.PERSON; INFILE "&filenm." firstobs=2 LRECL=10240 missover dsd; INPUT fname $ lname $ state $ imp ; run ; fname lname state imp James Smith KY 200 Maria Rodriguez NY 300
  • 9. External file in wrong column order data WORK.PERSON; INFILE "&filenm." firstobs=2 LRECL=10240 missover dsd; INPUT fname $ lname $ state $ imp ; run ; When data is stored in external file as fname imp lname state Thomas 100 Miller NY fname lname state imp Thomas 100 Mi .
  • 10. Appending wrong data proc append base =PROD.PERSON data =PERSON1; run; fname lname state imp James Smith KY 200 Maria Rodriguez NY 300 Thomas 100 Mi .
  • 11. Fixing column order issue • 1st step – make a macrovariable of column order of reference table/Production table proc sql noprint; select name into :standard separated by ',' from dictionary.columns where upper(libname) = 'PROD' and upper(memname) = 'PERSON'; quit;
  • 12. Fixing column order –2nd step options obs=1; PROC IMPORT OUT= WORK.PERSON1 DATAFILE= "/somelocation/person1.csv" DBMS=CSV REPLACE; GETNAMES=YES; DATAROW=2; RUN;
  • 13. Fixing column order –2nd step Contd.. proc sql noprint; select name into :test separated by ',' from dictionary.columns where upper(libname) = 'WORK' and upper(memname) = 'PERSON1'; quit;
  • 14. Fixing column length –final step %macro abc; Proc options obs =max; %if "&standard" = "&test " %then %do; DATA WORK.PERSON; INFILE "&filenm." firstobs=2 LRECL=10240 missover dsd; INFORMAT fname $6. lname : $9. state : $2. imp BEST32. ; INPUT fname $ lname $ state $ imp ; RUN; Proc append; Base = PROD.PERSON Data = WORK.PERSON1; Quit; %end; %else %do; %put “Something is wrong please inform your manager”; %mend abc;
  • 15. Longer column length issue when moving data from Hive to Teradata by SAS
  • 16. Issue when moving data from Hive to Teradata data teradb.shoppingmart; set hivedb.shoppingmart; run; • ERROR: Variable shoppingmartactivitymodification has been defined as both character and numeric
  • 17. Longer column name issue • maximum column name length allowed in hive (128), when compared to maximum column name length allowed in SAS (32) • shoppingmartactivitymodificationdatetime (character variable) shoppingmartactivitymodificationcustid (numeric variable). • After Truncation shoppingmartactivitymodification.
  • 18. Help from Dictionary.columns • name and label of dictionary.columns store name of DBMS table • In dictionary.columns, maximum allowed column name length is 32 and maximum allowed column label length is 256. • Column name of DBMS table is never truncated in label
  • 19. Help from Dictionary.columns contd.. proc sql; select a.name, a.label from dictionary.columns a inner join dictionary.columns b on a.memname = ' SHOPPINGMART' and a.libname = 'HIVE_DB' and a.name =b.name and a.label ne b.label; quit;
  • 20. Solution to long column length issue by PROC FEDSQL proc fedsql; create table teradb.SHOPPINGMART as select * from hive_db.SHOPPINGMART quit;
  • 21. Difference in number of columns while appending data from SAS to Teradata
  • 22. Failed Inserts proc sql; insert into TERADB.EMP select * from SASDB.EMP; quit; • ERROR: Attempt to insert fewer columns than specified after the INSERT table name
  • 23. Finding additional Columns proc sql; select * from dictionary.columns where memname = "EMP" and libname ='TERADB' and varnum not in (select varnum from dictionary.columns where memname = "EMP" and upcase(libname) ='SASDB'); quit;
  • 24. Solution to additional column length issue –step 1 proc sql noprint; select name into :columns separated by ',' from dictionary.columns where memname = "EMP" and upcase(libname) ='TERADB' and varnum in (select varnum from dictionary.columns where memname = "EMP" and libname ='SASDB');
  • 25. Solution to additional column length issue –final step proc sql; insert into TERADB.EMP(&columns) select * from SASDB.EMP; quit; • There are many other ways this problem can be solved
  • 26. Conclusion • Dictionary.columns are very helpful in understanding columns of the tables available in any library. • Dictionary.columns will give metadata information for columns of SAS tables along with other RDBMS tables. • Comparing columns between various heterogeneous sources can be done with help of Dictionary.columns.
  • 27. Thanks • Thanks for listening • I would like to specially thank, Paul Kirk Lafler for encouraging me to write papers. • I would like to thank, Lakshmi Nadiya Chintalapudi, Charannag Devarapalli , Sarika Elisetti, Anvesh Reddy Perati, Srirama Reddy, Suryakiran Pothuraju for helping me with proof reading and giving their valuable suggestions.