SlideShare a Scribd company logo
1 of 13
Download to read offline
46: NOBS for Noobs
David B. Horvath, CCP, MS
Presenter
The Author can be contacted at:
504 Longbotham Drive, Aston PA 19014-2502, USA
Phone: 1-610-859-8826
Email: dhorvath@cobs.com
Web: http://www.cobs.com/
LinkedIn: https://www.linkedin.com/in/dbhorvath/
All trademarks and servicemarks are the
property of their respective owners.
David B. Horvath, CCP, MS
Copyright © 2015-2021 David B. Horvath, CCP — All Rights Reserved
Abstract
This mini-session will be a short discussion of the NOBS (number of observations)
option on the SET statement.
This includes one "gotcha" that I've run into with where clauses: NOBS is set before
WHERE processing. If you have a reason to know the number of observations
after the WHERE clause, another DATA step is needed.
My Background
• David is an IT Professional who has worked with various platforms since the 1980’s with a
variety of development and analysis tools.
• He has presented at PhilaSUG, SESUG, and SGF previously and has presented workshops
and seminars in Australia, France, the US, Canada, and Oxford England (about the British
Author Nevil Shute).
• He holds an undergraduate degree in Computer and Information Sciences from Temple
University and a Masters in Organizational Dynamics from UPENN. He achieved the
Certified Computing Professional designation with honors.
• Most of his career has been in consulting (although recently he has been in-house) in the
Philadelphia PA area. He is currently in Data Analytics "Engineering" at a Regional Bank.
• He has several books to his credit (none SAS related) and is an Adjunct Instructor
covering IT topics.
Basic NOBS
• The nobs statement is a handy way of discovering how many
observations are in your SAS Dataset:
data simple;
a = 42;
output;
run;
data _null_;
put nobs=;
stop;
set simple nobs=nobs;
run;
• Prints
NOBS=1
Macro NOBS
• Great information if you need it!
• Is available before first row is processed
• Can be stored in macro variable for global usage:
data _null_;
call symput('ALLOBS', nobs);
stop;
set simple nobs=nobs;
run;
data _null_;
put "number of obs are &ALLOBS.";
stop;
run;
• Prints
number of obs are 1
NOBS – the catch: where
• Processing is at the file level – before the where clause:
data _null_;
put nobs=;
stop;
set simple nobs=nobs;
run;
• And
data _null_;
put nobs=;
stop;
set simple nobs=nobs;
where a = 10;
run;
• Both print the same result:
NOBS=1
NOBS – the catch: where
• I found out the hard way
• I had a process that rsubmitted N jobs to process the objects within
an XML file
• Each of the N jobs processed 1/Nth of the objects to spread load
• Process worked fine until the user said "Don't bother with THESE
tables".
• I figured "Oh, this is SAS, this is an easy change: 'where TABLE
not in (THESE1, THESE2, ... THESEn)'".
• The process worked fine but runtimes went up – no longer were N
processes running; the last 2 never started up.
• Solution was to add another data step in front to execute the
'where'
• Input to the rsubmit process now had the correct nobs
NOBS – the catch: not a new
variable
• Your nobs variable is special – it will not appear in the output
dataset
data new;
set simple nobs=nobs;
run;
proc print data=new; run;
• Prints
Obs a
1 42
• Coding the nobs variable in a keep statement is not a fix:
data new (keep=a nobs);
WARNING: The variable nobs in the DROP, KEEP, or RENAME
list has never been referenced.
• Only solution is an equal sign (even retain does not help):
nnobs=nobs;
NOBS – the catch: options obs=
• Is independent of options obs=;
options obs=2;
data _null_;
put nobs=;
stop;
set large nobs=nobs;
run;
• And (obs=)
data _null_;
put nobs=;
stop;
set large(obs=2) nobs=nobs;
run;
• Both print
nobs=915803
NOBS – the catch: not every engine
• The XML Engine does not properly implement:
filename SXLEMAP "OUR_MAP_FILE.map";
filename test2 "OUR_INPUT_FILE.xml";
libname test2 xml xmlmap=SXLEMAP access=READONLY;
NOTE: Libref TEST2 was successfully assigned as follows:
Engine: XML
Physical Name: TEST2
data _null_;
put nobs=;
stop;
set test2.application nobs=nobs;
run;
• Printing
nobs=9.0071993E15
• When the file only contained 17,383,357 bytes
Wrap Up
Questions
and
Answers
?!
?!
?!
?!
?
?
?
?
! !
! !
Presenter
David B. Horvath, CCP, MS
Copyright © 2015-2021 David B. Horvath, CCP — All Rights Reserved
The Author can be contacted at:
504 Longbotham Drive, Aston PA 19014-2502, USA
Phone: 1-610-859-8826
Email: dhorvath@cobs.com
Web: http://www.cobs.com/
LinkedIn: https://www.linkedin.com/in/dbhorvath/
All trademarks and servicemarks are the
property of their respective owners.

More Related Content

Similar to 202110 SESUG 46 NOBS for Noobs

Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Charley Hanania
 
NoSQL Solutions - a comparative study
NoSQL Solutions - a comparative studyNoSQL Solutions - a comparative study
NoSQL Solutions - a comparative study
Guillaume Lefranc
 

Similar to 202110 SESUG 46 NOBS for Noobs (20)

DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014
 
Hadoop for the Absolute Beginner
Hadoop for the Absolute BeginnerHadoop for the Absolute Beginner
Hadoop for the Absolute Beginner
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
 
202110 SESUG 43 To Compress or not
202110 SESUG 43 To Compress or not202110 SESUG 43 To Compress or not
202110 SESUG 43 To Compress or not
 
Big data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guideBig data Hadoop Analytic and Data warehouse comparison guide
Big data Hadoop Analytic and Data warehouse comparison guide
 
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBA
 
Bigdata ready reference
Bigdata ready referenceBigdata ready reference
Bigdata ready reference
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
 
DATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backupDATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backup
 
NoSQL Solutions - a comparative study
NoSQL Solutions - a comparative studyNoSQL Solutions - a comparative study
NoSQL Solutions - a comparative study
 
Neo4j Training Cypher
Neo4j Training CypherNeo4j Training Cypher
Neo4j Training Cypher
 
HADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCE
HADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCEHADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCE
HADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCE
 
Ceph Internals
Ceph InternalsCeph Internals
Ceph Internals
 
Data science and Hadoop
Data science and HadoopData science and Hadoop
Data science and Hadoop
 
Dbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo PiairoDbops, DevOps & Ops, by Eduardo Piairo
Dbops, DevOps & Ops, by Eduardo Piairo
 
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
 
Hadoop – big deal
Hadoop – big dealHadoop – big deal
Hadoop – big deal
 
Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)Make Life Suck Less (Building Scalable Systems)
Make Life Suck Less (Building Scalable Systems)
 
myHadoop 0.30
myHadoop 0.30myHadoop 0.30
myHadoop 0.30
 

Recently uploaded

TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 

Recently uploaded (20)

How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 

202110 SESUG 46 NOBS for Noobs

  • 1. 46: NOBS for Noobs David B. Horvath, CCP, MS
  • 2. Presenter The Author can be contacted at: 504 Longbotham Drive, Aston PA 19014-2502, USA Phone: 1-610-859-8826 Email: dhorvath@cobs.com Web: http://www.cobs.com/ LinkedIn: https://www.linkedin.com/in/dbhorvath/ All trademarks and servicemarks are the property of their respective owners. David B. Horvath, CCP, MS Copyright © 2015-2021 David B. Horvath, CCP — All Rights Reserved
  • 3. Abstract This mini-session will be a short discussion of the NOBS (number of observations) option on the SET statement. This includes one "gotcha" that I've run into with where clauses: NOBS is set before WHERE processing. If you have a reason to know the number of observations after the WHERE clause, another DATA step is needed.
  • 4. My Background • David is an IT Professional who has worked with various platforms since the 1980’s with a variety of development and analysis tools. • He has presented at PhilaSUG, SESUG, and SGF previously and has presented workshops and seminars in Australia, France, the US, Canada, and Oxford England (about the British Author Nevil Shute). • He holds an undergraduate degree in Computer and Information Sciences from Temple University and a Masters in Organizational Dynamics from UPENN. He achieved the Certified Computing Professional designation with honors. • Most of his career has been in consulting (although recently he has been in-house) in the Philadelphia PA area. He is currently in Data Analytics "Engineering" at a Regional Bank. • He has several books to his credit (none SAS related) and is an Adjunct Instructor covering IT topics.
  • 5. Basic NOBS • The nobs statement is a handy way of discovering how many observations are in your SAS Dataset: data simple; a = 42; output; run; data _null_; put nobs=; stop; set simple nobs=nobs; run; • Prints NOBS=1
  • 6. Macro NOBS • Great information if you need it! • Is available before first row is processed • Can be stored in macro variable for global usage: data _null_; call symput('ALLOBS', nobs); stop; set simple nobs=nobs; run; data _null_; put "number of obs are &ALLOBS."; stop; run; • Prints number of obs are 1
  • 7. NOBS – the catch: where • Processing is at the file level – before the where clause: data _null_; put nobs=; stop; set simple nobs=nobs; run; • And data _null_; put nobs=; stop; set simple nobs=nobs; where a = 10; run; • Both print the same result: NOBS=1
  • 8. NOBS – the catch: where • I found out the hard way • I had a process that rsubmitted N jobs to process the objects within an XML file • Each of the N jobs processed 1/Nth of the objects to spread load • Process worked fine until the user said "Don't bother with THESE tables". • I figured "Oh, this is SAS, this is an easy change: 'where TABLE not in (THESE1, THESE2, ... THESEn)'". • The process worked fine but runtimes went up – no longer were N processes running; the last 2 never started up. • Solution was to add another data step in front to execute the 'where' • Input to the rsubmit process now had the correct nobs
  • 9. NOBS – the catch: not a new variable • Your nobs variable is special – it will not appear in the output dataset data new; set simple nobs=nobs; run; proc print data=new; run; • Prints Obs a 1 42 • Coding the nobs variable in a keep statement is not a fix: data new (keep=a nobs); WARNING: The variable nobs in the DROP, KEEP, or RENAME list has never been referenced. • Only solution is an equal sign (even retain does not help): nnobs=nobs;
  • 10. NOBS – the catch: options obs= • Is independent of options obs=; options obs=2; data _null_; put nobs=; stop; set large nobs=nobs; run; • And (obs=) data _null_; put nobs=; stop; set large(obs=2) nobs=nobs; run; • Both print nobs=915803
  • 11. NOBS – the catch: not every engine • The XML Engine does not properly implement: filename SXLEMAP "OUR_MAP_FILE.map"; filename test2 "OUR_INPUT_FILE.xml"; libname test2 xml xmlmap=SXLEMAP access=READONLY; NOTE: Libref TEST2 was successfully assigned as follows: Engine: XML Physical Name: TEST2 data _null_; put nobs=; stop; set test2.application nobs=nobs; run; • Printing nobs=9.0071993E15 • When the file only contained 17,383,357 bytes
  • 13. Presenter David B. Horvath, CCP, MS Copyright © 2015-2021 David B. Horvath, CCP — All Rights Reserved The Author can be contacted at: 504 Longbotham Drive, Aston PA 19014-2502, USA Phone: 1-610-859-8826 Email: dhorvath@cobs.com Web: http://www.cobs.com/ LinkedIn: https://www.linkedin.com/in/dbhorvath/ All trademarks and servicemarks are the property of their respective owners.