All data (tables x and y) are dynamically generated in the script using loops and random functions (uniform, ranuni).
1 Code Block
DATA STEP Data
Explanation : Generation of source table 'x' with 3 iterations (i from 0 to 2).
Copied!
data x ;
do i=0 to 2 ;
j=round(uniform(i)*10) ;
put _all_ ;
output ;
end ;
run ;
1
DATA x ;
2
DO i=0 to 2 ;
3
j=round(uniform(i)*10) ;
4
put _all_ ;
5
OUTPUT ;
6
END ;
7
RUN ;
2 Code Block
DATA STEP Data
Explanation : Generation of lookup table 'y' with immediate creation of an index on variable 'i'.
Copied!
data y(index=(i)) ;
do i=1 to 4 ;
j=round(ranuni(i)*3) ;
do k=1 to j ;
put _all_ ;
output ;
end ;
end ;
run ;
1
DATA y(index=(i)) ;
2
DO i=1 to 4 ;
3
j=round(ranuni(i)*3) ;
4
DO k=1 to j ;
5
put _all_ ;
6
OUTPUT ;
7
END ;
8
END ;
9
RUN ;
3 Code Block
DATA STEP Data
Explanation : DATA step reading 'x' sequentially and accessing 'y' via index 'i' (KEY=i). Displaying _IORC_ allows checking for index lookup success.
Copied!
data z ;
set x(in=in_x) ;
set y(in=in_y) key=i ;
put _iorc_= _all_ / ;
run ;
1
DATA z ;
2
SET x(in=in_x) ;
3
SET y(in=in_y) key=i ;
4
put _iorc_= _all_ / ;
5
RUN ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Related Documentation
Aucune documentation spécifique pour cette catégorie.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.