Sample 24774: Generate a SASĀ® data set for testing purposes
Use an iterative DO loop to generate a SAS data set. Click on the FULL CODE tab for sample code.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* The following code generates a SAS data set with 30 */
/* observations, 3 numeric variables, and 1 character */
/* variable. */
data testdata;
y=1;
do i=1 to 30;
x=i+1;
y=y+x;
z=y+4;
a='abc'||trim(left(put(i,2.)));
output;
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs y i x z a
1 3 1 2 7 abc1
2 6 2 3 10 abc2
3 10 3 4 14 abc3
4 15 4 5 19 abc4
5 21 5 6 25 abc5
6 28 6 7 32 abc6
7 36 7 8 40 abc7
8 45 8 9 49 abc8
9 55 9 10 59 abc9
10 66 10 11 70 abc10
11 78 11 12 82 abc11
12 91 12 13 95 abc12
13 105 13 14 109 abc13
14 120 14 15 124 abc14
15 136 15 16 140 abc15
16 153 16 17 157 abc16
17 171 17 18 175 abc17
18 190 18 19 194 abc18
19 210 19 20 214 abc19
20 231 20 21 235 abc20
21 253 21 22 257 abc21
22 276 22 23 280 abc22
23 300 23 24 304 abc23
24 325 24 25 329 abc24
25 351 25 26 355 abc25
26 378 26 27 382 abc26
27 406 27 28 410 abc27
28 435 28 29 439 abc28
29 465 29 30 469 abc29
30 496 30 31 500 abc30
Use an iterative DO loop to generate a SAS data set.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Data Management ==> Manipulation and Transformation ==> Array processing
|
| Date Modified: | 2005-12-08 11:34:33 |
| Date Created: | 2004-09-30 14:09:13 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |