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

PPT
20150312 NOBS for Noobs
PDF
rhbase_tutorial
PDF
Next Generation Hadoop Operations
PDF
Oracle Database : Addressing a performance issue the drilldown approach
PPT
Delphix for DBAs by Jonathan Lewis
PDF
Adop patching gotchas ppt
PPTX
20170419 To COMPRESS or Not, to COMPRESS or ZIP
PDF
Big data hadooop analytic and data warehouse comparison guide
20150312 NOBS for Noobs
rhbase_tutorial
Next Generation Hadoop Operations
Oracle Database : Addressing a performance issue the drilldown approach
Delphix for DBAs by Jonathan Lewis
Adop patching gotchas ppt
20170419 To COMPRESS or Not, to COMPRESS or ZIP
Big data hadooop analytic and data warehouse comparison guide

Similar to 202110 SESUG 46 NOBS for Noobs (20)

PDF
DIG1108C Lesson3 Fall 2014
PPTX
Hadoop for the Absolute Beginner
PPTX
Dapper: the microORM that will change your life
PDF
202110 SESUG 43 To Compress or not
PDF
Big data Hadoop Analytic and Data warehouse comparison guide
PPTX
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
PDF
The 5 Minute MySQL DBA
PDF
Bigdata ready reference
PDF
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
PDF
DATABASE AUTOMATION with Thousands of database, monitoring and backup
PDF
NoSQL Solutions - a comparative study
PDF
Neo4j Training Cypher
PPTX
HADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCE
PDF
Ceph Internals
PPTX
Data science and Hadoop
PPTX
Dbops, DevOps & Ops, by Eduardo Piairo
PDF
NoSql and it's introduction features-Unit-1.pdf
PDF
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
PPSX
Hadoop – big deal
KEY
Make Life Suck Less (Building Scalable Systems)
DIG1108C Lesson3 Fall 2014
Hadoop for the Absolute Beginner
Dapper: the microORM that will change your life
202110 SESUG 43 To Compress or not
Big data Hadoop Analytic and Data warehouse comparison guide
Pass chapter meeting dec 2013 - compression a hidden gem for io heavy databas...
The 5 Minute MySQL DBA
Bigdata ready reference
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
DATABASE AUTOMATION with Thousands of database, monitoring and backup
NoSQL Solutions - a comparative study
Neo4j Training Cypher
HADOOP DISTRIBUTED FILE SYSTEM AND MAPREDUCE
Ceph Internals
Data science and Hadoop
Dbops, DevOps & Ops, by Eduardo Piairo
NoSql and it's introduction features-Unit-1.pdf
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Hadoop – big deal
Make Life Suck Less (Building Scalable Systems)
Ad

Recently uploaded (20)

PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PPTX
Configure Apache Mutual Authentication
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Architecture types and enterprise applications.pdf
PPTX
The various Industrial Revolutions .pptx
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Flame analysis and combustion estimation using large language and vision assi...
1 - Historical Antecedents, Social Consideration.pdf
Chapter 5: Probability Theory and Statistics
The influence of sentiment analysis in enhancing early warning system model f...
Configure Apache Mutual Authentication
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Getting started with AI Agents and Multi-Agent Systems
A comparative study of natural language inference in Swahili using monolingua...
Architecture types and enterprise applications.pdf
The various Industrial Revolutions .pptx
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Hindi spoken digit analysis for native and non-native speakers
UiPath Agentic Automation session 1: RPA to Agents
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A proposed approach for plagiarism detection in Myanmar Unicode text
Two-dimensional Klein-Gordon and Sine-Gordon numerical solutions based on dee...
sbt 2.0: go big (Scala Days 2025 edition)
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Ad

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.