Data input and output in SAS are: 1. By column: Input variable name <$> < start position > <-End Position >
Data score; /* Create a data set on the score */
Input name $1-10 Math 11-12 Chinese 17-18 中文版 26-27; /* For each variable, enter data by column */
Datalines; /* Tip Below is the data line */
Bital 90 92 88
Martin 80 95 94
Run
2. List input: Input variable name <$> < input format > <@|@@>
Data /* Data set name default, default is data1*/
Length City $9/* Specifies that the length of the character variable is 9 (the default is 8 bytes and the extra length is truncated) */;
Input City $ sales/* List enter variable: city, sales*/;
Cards /* Hint below is the data row, equivalent to Datalines */
Shenzhen 8000
Guangdong 5000
Shanghai 10000
Beijing 12000
Run
3. Format input:
Data
Input ID 4. @9 name $. @25 sex $. @31 age 2. @38 salary comma6.; /* Use format input */
Cards
2458 Murray,w M 27 11,579
2459 Almers,c F 34 13,640
2460 Johonson,r M 38 22,713
Run
4. Data output
Output to SAS window: File identification name < options log|print>
Output to external file: file ' path ' < options >;
Data price;
Format Date yymmdd10.; /* Set the variable date output format for the dates output format: yymmdd10.*/
Format City $.; /* The character output format of the set Variable city is: $2.*/
Format Price1 6.2; /* The value output format of the variable Price1 is: 6.2*/
Format PRICE2 6.2; /* The value output format of the variable PRICE2 is: 6.2*/
Format Price3 7.2; /* The value output format of the variable price3 is: 7.2*/
Informat date date9.; /* Set the variable date input format for the dates output format: date9.*/
Informat City. /* The character input format for setting the variable city is: $2.*/
Informat Price1 12.8; /* The numeric input format for setting the variable Price1 is: 12.8*/
Informat Price2 12.8; /* The numeric input format for setting the variable price2 is: 12.8*/
Informat Price3 12.7; /* The numeric input format for setting the variable price3 is: 12.7*/
Input Date City $ price1 price2 price3; /* Use list input */
Cards
11jan2017 SZ 721.91999912 138.80999994 2434.3699999
28feb2017 SH 715.19999981 137.73999995 2410.6399994
05mar2017 GZ 708.58999943 150.13 2455.0099993
;
Run
Proc Print Data=price;
Run