SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
SASTechies [email_address] http://www.sastechies.com
A SAS  array  is a temporary grouping of SAS variables under a single name. An array exists only for the duration of the DATA step.  data  work.report;  input mon tue wed thr fri sat sun; put _all_; mon= 5 *(mon- 32 )/ 9 ;  tue= 5 *(tue- 32 )/ 9 ; wed= 5 *(wed- 32 )/ 9 ; thr= 5 *(thr- 32 )/ 9 ; fri= 5 *(fri- 32 )/ 9 ;  sat= 5 *(sat- 32 )/ 9 ; sun= 5 *(sun- 32 )/ 9 ;  put _all_; cards; 100 103 100 107 90 65 56 70 30 32 40 50 80 0 ; run ; data work.report; set master.temps;  array wkday(7) mon tue wed thr fri sat sun;   do i=1 to 7; wkday(i) =5*( wkday(i) -32)/9; end;  run;  SAS Techies  2009 ARRAY  array-name { dimension }   elements ;   where  array-name  specifies the name of the array  dimension  describes the number and arrangement of array elements  elements  lists the variables to include in the array.  array  sales  {4};  array  sales  {4} qtr1 qtr2 qtr3 qtr4;  array sales  {*}  qtr1 qtr2 qtr3 qtr4;  array sales{4}  qtr1- qtr4 ;  array goal{4} g1 g2 g3 g4 ( 9000 9300 9600 9900 );  11/13/09
SAS Techies  2009 SAS Data Set Hrd.Fitclass  11/13/09 Name  Weight1 Weight2 Weight3  Weight4 Weight5 Weight6  Alicia  69.6  68.9  68.8  52.6  52.6  51.7  Brenda 68.6  67.6  67.0  67.6  66.6  66.0
data  score2(drop=i); array test{ 3 }  _temporary_  ( 90   80   70 ); array score{ 3 } s1-s3; input id score{*}; do i= 1  to  3 ; if score{i}>=test{i} then do; NewScore=score{i}; output; end; end; datalines; 1234  99 60 82 5678  80 85 75 ; run ; create temporary array elements for DATA step processing without creating new variables by specifying  _TEMPORARY_   Temporary array elements do not appear in the resulting data set.  Temporary array elements are useful when the array is only needed to perform a calculation.  You can improve performance time by using temporary array elements. SAS Techies  2009 11/13/09
SAS Techies  2009 array new{ r , c } x1-x12;  array month{3,4}  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ;  Array Q{4}; do i=1 to 4;   Total=0; do j=1 to 3;   Q(i)=total+mon(i,j);   end;   end;   11/13/09                                                   array new{12}  x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ;
SAS Techies  2009 data finance.quarters(drop=i j);  set finance.monthly;  array m(4,3) month1-month12; array Qtr(4);  do i=1 to  dim( Qtr ) ; do j=1 to 3;  qtr(i)+m(i,j); end;  end; run;  11/13/09
data  temps; array temprg{ 2 , 5 } c1t1-c1t5 c2t1-c2t5; input City1 $ c1t1-c1t5 / City2 $ c2t1-c2t5; do i= 1  to  2 ; do j= 1  to  5 ; temprg{i,j}=round(temprg{i,j}); end; end; datalines; Fairfax 89.5 65.4 75.3 77.7 89.3 Frederic 73.7 87.3 89.9 98.2 35.6 Fairfax 75.8 82.1 98.2 93.5 67.7 Frederic 101.3 86.5 59.2 35.6 75.7 ; run ; 11/13/09 SAS Techies  2009

More Related Content

PPT
SAS Macros
PPT
SAS Macros part 1
PPT
SAS Macros part 2
PPT
Base SAS Statistics Procedures
PDF
SAS cheat sheet
PPT
Data Match Merging in SAS
PPT
Utility Procedures in SAS
PPT
Basics Of SAS Programming Language
SAS Macros
SAS Macros part 1
SAS Macros part 2
Base SAS Statistics Procedures
SAS cheat sheet
Data Match Merging in SAS
Utility Procedures in SAS
Basics Of SAS Programming Language

What's hot (20)

PPT
SAS Functions
DOCX
Sas practice programs
PPTX
Data visualization using R
PPT
Visualizing Proc Transpose
PPTX
Sas Functions INDEX / INDEXC / INDEXW
PDF
Sas cheat
PPTX
SAS Macro
PPT
SAS BASICS
PPTX
Proc SQL in SAS Enterprise Guide 4.3
PPT
Where Vs If Statement
PPTX
Calculated Fields in Tableau
PPTX
SQL Queries Information
PPT
PHP mysql Mysql joins
PPT
SAS Access / SAS Connect
PPT
Introduction to-sql
PPTX
Introduction to R
PPTX
SQL - DML and DDL Commands
PPT
Conditional statements in sas
ODP
PPT
Sas Plots Graphs
SAS Functions
Sas practice programs
Data visualization using R
Visualizing Proc Transpose
Sas Functions INDEX / INDEXC / INDEXW
Sas cheat
SAS Macro
SAS BASICS
Proc SQL in SAS Enterprise Guide 4.3
Where Vs If Statement
Calculated Fields in Tableau
SQL Queries Information
PHP mysql Mysql joins
SAS Access / SAS Connect
Introduction to-sql
Introduction to R
SQL - DML and DDL Commands
Conditional statements in sas
Sas Plots Graphs
Ad

Viewers also liked (11)

PPT
Improving Effeciency with Options in SAS
PPT
SAS ODS HTML
PPT
SAS Proc SQL
PPT
Understanding SAS Data Step Processing
PDF
Base SAS Exam Questions
PDF
scorereport
PPT
Reading Fixed And Varying Data
PPSX
SAS TRAINING
PDF
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
DOCX
Sas Macro Examples
DOCX
Learn SAS Programming
Improving Effeciency with Options in SAS
SAS ODS HTML
SAS Proc SQL
Understanding SAS Data Step Processing
Base SAS Exam Questions
scorereport
Reading Fixed And Varying Data
SAS TRAINING
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Sas Macro Examples
Learn SAS Programming
Ad

Similar to Arrays in SAS (20)

PDF
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
PPT
arrays
PDF
M 0 1 2 3 4 5 6 7 0.pdf
PPTX
Seminar PSU 10.10.2014 mme
KEY
TDD Boot Camp 東京 for C++ 進行
PPT
Whats new in_csharp4
PDF
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
PPT
Unit8
ODP
Introduction To PostGIS
PPTX
Arrays
PDF
Idea for ineractive programming language
PDF
Lecture06 computer applicationsie1_dratifshahzad
PDF
R Programming: Numeric Functions In R
DOCX
IMG1.jpgIMG2.jpgIMG3.jpg2016 6 19 156 Page .docx
PPT
Dynamically Evolving Systems: Cluster Analysis Using Time
PPTX
2011 nri-pratiques tests-avancees
PPTX
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
PDF
ES6 Simplified
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
arrays
M 0 1 2 3 4 5 6 7 0.pdf
Seminar PSU 10.10.2014 mme
TDD Boot Camp 東京 for C++ 進行
Whats new in_csharp4
Solution Manual for Data Structures and Algorithm Analysis in C++, 4/E 4th Ed...
Unit8
Introduction To PostGIS
Arrays
Idea for ineractive programming language
Lecture06 computer applicationsie1_dratifshahzad
R Programming: Numeric Functions In R
IMG1.jpgIMG2.jpgIMG3.jpg2016 6 19 156 Page .docx
Dynamically Evolving Systems: Cluster Analysis Using Time
2011 nri-pratiques tests-avancees
Egor Bogatov - .NET Core intrinsics and other micro-optimizations
ES6 Simplified

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Spectroscopy.pptx food analysis technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Electronic commerce courselecture one. Pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectroscopy.pptx food analysis technology

Arrays in SAS

  • 2. A SAS array is a temporary grouping of SAS variables under a single name. An array exists only for the duration of the DATA step. data work.report; input mon tue wed thr fri sat sun; put _all_; mon= 5 *(mon- 32 )/ 9 ; tue= 5 *(tue- 32 )/ 9 ; wed= 5 *(wed- 32 )/ 9 ; thr= 5 *(thr- 32 )/ 9 ; fri= 5 *(fri- 32 )/ 9 ; sat= 5 *(sat- 32 )/ 9 ; sun= 5 *(sun- 32 )/ 9 ; put _all_; cards; 100 103 100 107 90 65 56 70 30 32 40 50 80 0 ; run ; data work.report; set master.temps; array wkday(7) mon tue wed thr fri sat sun; do i=1 to 7; wkday(i) =5*( wkday(i) -32)/9; end; run; SAS Techies 2009 ARRAY array-name { dimension } elements ; where array-name specifies the name of the array dimension describes the number and arrangement of array elements elements lists the variables to include in the array. array sales {4}; array sales {4} qtr1 qtr2 qtr3 qtr4; array sales {*} qtr1 qtr2 qtr3 qtr4; array sales{4} qtr1- qtr4 ; array goal{4} g1 g2 g3 g4 ( 9000 9300 9600 9900 ); 11/13/09
  • 3. SAS Techies 2009 SAS Data Set Hrd.Fitclass 11/13/09 Name Weight1 Weight2 Weight3 Weight4 Weight5 Weight6 Alicia 69.6 68.9 68.8 52.6 52.6 51.7 Brenda 68.6 67.6 67.0 67.6 66.6 66.0
  • 4. data score2(drop=i); array test{ 3 } _temporary_ ( 90 80 70 ); array score{ 3 } s1-s3; input id score{*}; do i= 1 to 3 ; if score{i}>=test{i} then do; NewScore=score{i}; output; end; end; datalines; 1234 99 60 82 5678 80 85 75 ; run ; create temporary array elements for DATA step processing without creating new variables by specifying _TEMPORARY_ Temporary array elements do not appear in the resulting data set. Temporary array elements are useful when the array is only needed to perform a calculation. You can improve performance time by using temporary array elements. SAS Techies 2009 11/13/09
  • 5. SAS Techies 2009 array new{ r , c } x1-x12; array month{3,4} x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ; Array Q{4}; do i=1 to 4; Total=0; do j=1 to 3; Q(i)=total+mon(i,j); end; end; 11/13/09                                                   array new{12} x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ;
  • 6. SAS Techies 2009 data finance.quarters(drop=i j); set finance.monthly; array m(4,3) month1-month12; array Qtr(4); do i=1 to dim( Qtr ) ; do j=1 to 3; qtr(i)+m(i,j); end; end; run; 11/13/09
  • 7. data temps; array temprg{ 2 , 5 } c1t1-c1t5 c2t1-c2t5; input City1 $ c1t1-c1t5 / City2 $ c2t1-c2t5; do i= 1 to 2 ; do j= 1 to 5 ; temprg{i,j}=round(temprg{i,j}); end; end; datalines; Fairfax 89.5 65.4 75.3 77.7 89.3 Frederic 73.7 87.3 89.9 98.2 35.6 Fairfax 75.8 82.1 98.2 93.5 67.7 Frederic 101.3 86.5 59.2 35.6 75.7 ; run ; 11/13/09 SAS Techies 2009

Editor's Notes

  • #3: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #4: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #5: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #6: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #7: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #8: SASTechies.com Sharad C Narnindi - Attic Technologies 2005