Shanghai those things

Surrogacy is located in Shanghai, is a professional surrogate agency center, add a formal surrogacy in Shanghai: ██╇ micro-channel: 138 ★ 0226 ★ 9370╇██ mainly engaged in Shanghai surrogate agency and surrogacy services and care, Shanghai reasonable behalf maternal child price and strict the surrogacy process.

2.5 Higher Order data reading method

2.5.1 Options control input (infile option) in INFILE statement

infile statement option, on the back infile statement in the file name, you can change the SAS to read the original data file mode, useful for reading certain types of data files.

FIRSTOBS=

SAS is used to inform begin reading data from the first few lines. This descriptive text and data file header information which is very useful at the beginning.

OBS=

SAS is used to tell which rows to read the data file to stop. "OBS =" option and often "FIRSTOBS =" option is used together to read the file from the middle of the data file

MISS OVER

After the default, SAS read a line of data input statement if there are some variables are not assigned, SAS will read the data in the next row. "MISSOVER" option tells SAS: When a row of data read do not go to the next line, but assigned missing values for the remaining variables.

TRUNCOVER

When you use column input or read data input format, and some of the data line than other lines short, you need to use the "TRUNCOVER" option, inform SAS as a variable to read data when this option is action, until it encounters a data line the end of, or met the last row or column in the format specified range. Whichever is the first to meet the person.

TRUNCOVER and MISSOVER similar, to distinguish between:

  • Contact: If data is over before the start line variable scope, they are assigned missing values ​​for the variables
  • Difference: if the end of the data line intermediate variable scope, TRUNCOVER will try to read available data, the missing value MISSOVER assigned directly a variable

 

2.5.2 DATA step to read delimited file (infile option)

Delimited file is a special character delimited data using the original data file value, usually a comma (,) or tab (Tab) as a separator, the SAS option offers even make it easier to read infile statement: DLM =  options and  DSD  options.

DLM = Options

If desired the read data file separator is a space, a list may be used to read the input data. But if other delimiters, then you need to use the statement infile DELIMITER =  or  DLM =  option to use any of the read data file delimiter, the delimiter party need only  DLM =  back of the equal sign in options (e.g. DLM = '&'). If the separator is a string, the  DLMSTR =  option.

Example: infile 'D: \ code \ test.dat' DLM = ',';

Note that, if the sub-element with tabs (Tab) separated, the DLM = '09'X (ASCII code).

DSD Options

By default, SAS two or more consecutive delimiters interpreted as a delimiter. If your files are missing, and two consecutive delimiters representing missing values will be used to DSD option infile statement (delimiter sensitive data), it has a three-effect and can be used with  DLM =  option.

  • Ignore enclosed in quotation marks delimiter data values
  • Will not read as part of the value quoted
  • The two consecutive delimiters as deletion

Example: infile 'file - specification' DLM = '09'X DSD;

CSV file

Comma delimited file CSV file is called, for these files, usually DSD option for reading. But there is a special case: It may appear at the end of the data line missing values, then you need to  DSD options  and  MISSOVER option  in conjunction, SAS informed when a row of data is not enough, do not jump to continue reading the next line.

Example: infile 'D: \ code \ test.csv' DLM = ',' dsd missover;

 

2.5.3 IMPORT delimited file read process (Import)

SAS is usually more than one way to achieve the same results

Already learned to read the DATA step delimited file, IMPORT next learning process, can achieve the same result.

PROC IMPORT

import process automatically scan lines before the data file 20 to confirm the automatic variable type (numeric or string). It also specifies the length of the identification number and the date format for the character. Meanwhile, proc import data file will consecutive delimiters as missing values, the value of the read data included in quotes, and when data is read for the remaining missing values ​​assigned to the variables. Further, as needed, to the first row in the data file as a name of the variable.

示例:proc import datafile = 'filename' out = data-set ;

filename is the name of the file you want to read, data - set is the name of a SAS data set to be created. At the same time, SAS will confirm the type of file by file name expansion:

file type Expand the name DBMS identifier
Comma-separated .csv CSV
Tab-separated .txt TAB
Use of other delimiters   DLM

If the files are not properly expand name, or some kind of DLM file type, you must then use the proc import the  DLMS =  option. If you already have one and  OUT =  SAS data set options of the same name, and want to cover it, you need to use the  REPLACE  option.

proc import datafile = 'filename' out = data-set
     dbms = identifier replace ;

Optional statement

Some file types need some extra instruction to read them properly.

  • If the data file is not in the first line, you can use  DATAROWS  statement
  • If the symbol is not a comma separated, spaces or tabs, may be used  DELIMITER  statement
  • If the file contains data only, no header row, you can use  GETNAMES = NO  statement assigns a default variable name
  • If the data in the first 20 lines are all missing values or no representative data may be used  GUESSINGROWS  statement, a variable is assigned to ensure the correct data type and length
datarows = n;                         /* 从第n行开始读取数据,默认是1 */
delimiter = 'delimiter-character';    /* DLM文件的分隔符,默认是空格 */
getnames = no; /* 不要从输入文件的第一行获取变量名称,默认yes;如果是no,变 量名称为var1、var2、var3等 */ guessingrows = n; /* 使用n行来确定变量的类型,默认20 */
proc import datafile = 'D:\code\test.csv' out = music replace;
run;

 

2.5.4 use the IMPORT process of reading Excel files (import)

Can be used in SAS  PROC IMPORT  procedure to read Excel files, it should be noted that import process (windows and unix) Usage there are some differences in different systems:

The import process to read Excel files are generally in the form of:

proc import datafile = 'filename' out = data-set
     dbms = identifier replace ;

Where filename is the file to be read; data-set is SAS dataset name to be created; replace option is to tell SAS to replace out = option specified in the data set (if present) dbms = option tells Excel SAS to read file type, but it is not required.

DBMS identifier

The three most commonly used identifier is excel, xls, xlsx.

  • unix system: xls to read the file (expand name .xls); xlsx to read the file (expand name .xlsx)
  • windows system: xls, xlsx usage with unix, and more excel identifiers can read all types of excel file

Is the need to distinguish between, excel identifier uses a different technique to read, so results may vary. By default, xls, xlsx excel compared to the identifier will see more rows of data to determine the type of column.

Optional statement

If the file has multiple worksheets, you can use  SHEET  statement to be read to specify the worksheet.

语法:sheet = "sheet-name" ;

If you want to read a particular worksheet cell can  range  specify a region. The region may be a region name (if defined), or may be mounted in the following manner to specify the upper left and lower right cell where the prefetch. a

语法:range = "sheet-name$UL:LR" ;

By default, the first row of the spreadsheet import using the procedure as a variable name. If you do not want to do this, you can add to the process  GETNAMES  statement (excel identifier only), SAS will these variables named F1, F2 and so on.

Syntax: getnames = no;

When using excel identifier, if there is a value and a character value contains. By default, the value will be converted to missing values. To read the value to the missing values instead of the character type, can be used  MIXED  statement.

Syntax: mixed = yes;

proc import datafile = 'D:\code\test.csv' dbms = xls out = music replace;
run;
 
Category:  SAS

2.5 Higher Order data reading method

2.5.1 Options control input (infile option) in INFILE statement

infile statement option, on the back infile statement in the file name, you can change the SAS to read the original data file mode, useful for reading certain types of data files.

FIRSTOBS=

SAS is used to inform begin reading data from the first few lines. This descriptive text and data file header information which is very useful at the beginning.

OBS=

SAS is used to tell which rows to read the data file to stop. "OBS =" option and often "FIRSTOBS =" option is used together to read the file from the middle of the data file

MISS OVER

After the default, SAS read a line of data input statement if there are some variables are not assigned, SAS will read the data in the next row. "MISSOVER" option tells SAS: When a row of data read do not go to the next line, but assigned missing values for the remaining variables.

TRUNCOVER

When you use column input or read data input format, and some of the data line than other lines short, you need to use the "TRUNCOVER" option, inform SAS as a variable to read data when this option is action, until it encounters a data line the end of, or met the last row or column in the format specified range. Whichever is the first to meet the person.

TRUNCOVER and MISSOVER similar, to distinguish between:

  • Contact: If data is over before the start line variable scope, they are assigned missing values ​​for the variables
  • Difference: if the end of the data line intermediate variable scope, TRUNCOVER will try to read available data, the missing value MISSOVER assigned directly a variable

 

2.5.2 DATA step to read delimited file (infile option)

Delimited file is a special character delimited data using the original data file value, usually a comma (,) or tab (Tab) as a separator, the SAS option offers even make it easier to read infile statement: DLM =  options and  DSD  options.

DLM = Options

If desired the read data file separator is a space, a list may be used to read the input data. But if other delimiters, then you need to use the statement infile DELIMITER =  or  DLM =  option to use any of the read data file delimiter, the delimiter party need only  DLM =  back of the equal sign in options (e.g. DLM = '&'). If the separator is a string, the  DLMSTR =  option.

Example: infile 'D: \ code \ test.dat' DLM = ',';

Note that, if the sub-element with tabs (Tab) separated, the DLM = '09'X (ASCII code).

DSD Options

By default, SAS two or more consecutive delimiters interpreted as a delimiter. If your files are missing, and two consecutive delimiters representing missing values will be used to DSD option infile statement (delimiter sensitive data), it has a three-effect and can be used with  DLM =  option.

  • Ignore enclosed in quotation marks delimiter data values
  • Will not read as part of the value quoted
  • The two consecutive delimiters as deletion

Example: infile 'file - specification' DLM = '09'X DSD;

CSV file

Comma delimited file CSV file is called, for these files, usually DSD option for reading. But there is a special case: It may appear at the end of the data line missing values, then you need to  DSD options  and  MISSOVER option  in conjunction, SAS informed when a row of data is not enough, do not jump to continue reading the next line.

Example: infile 'D: \ code \ test.csv' DLM = ',' dsd missover;

 

2.5.3 IMPORT delimited file read process (Import)

SAS is usually more than one way to achieve the same results

Already learned to read the DATA step delimited file, IMPORT next learning process, can achieve the same result.

PROC IMPORT

import process automatically scan lines before the data file 20 to confirm the automatic variable type (numeric or string). It also specifies the length of the identification number and the date format for the character. Meanwhile, proc import data file will consecutive delimiters as missing values, the value of the read data included in quotes, and when data is read for the remaining missing values ​​assigned to the variables. Further, as needed, to the first row in the data file as a name of the variable.

示例:proc import datafile = 'filename' out = data-set ;

filename is the name of the file you want to read, data - set is the name of a SAS data set to be created. At the same time, SAS will confirm the type of file by file name expansion:

file type Expand the name DBMS identifier
Comma-separated .csv CSV
Tab-separated .txt TAB
Use of other delimiters   DLM

If the files are not properly expand name, or some kind of DLM file type, you must then use the proc import the  DLMS =  option. If you already have one and  OUT =  SAS data set options of the same name, and want to cover it, you need to use the  REPLACE  option.

proc import datafile = 'filename' out = data-set
     dbms = identifier replace ;

Optional statement

Some file types need some extra instruction to read them properly.

  • If the data file is not in the first line, you can use  DATAROWS  statement
  • If the symbol is not a comma separated, spaces or tabs, may be used  DELIMITER  statement
  • If the file contains data only, no header row, you can use  GETNAMES = NO  statement assigns a default variable name
  • If the data in the first 20 lines are all missing values or no representative data may be used  GUESSINGROWS  statement, a variable is assigned to ensure the correct data type and length
datarows = n;                         /* 从第n行开始读取数据,默认是1 */
delimiter = 'delimiter-character';    /* DLM文件的分隔符,默认是空格 */
getnames = no; /* 不要从输入文件的第一行获取变量名称,默认yes;如果是no,变 量名称为var1、var2、var3等 */ guessingrows = n; /* 使用n行来确定变量的类型,默认20 */
proc import datafile = 'D:\code\test.csv' out = music replace;
run;

 

2.5.4 use the IMPORT process of reading Excel files (import)

Can be used in SAS  PROC IMPORT  procedure to read Excel files, it should be noted that import process (windows and unix) Usage there are some differences in different systems:

The import process to read Excel files are generally in the form of:

proc import datafile = 'filename' out = data-set
     dbms = identifier replace ;

Where filename is the file to be read; data-set is SAS dataset name to be created; replace option is to tell SAS to replace out = option specified in the data set (if present) dbms = option tells Excel SAS to read file type, but it is not required.

DBMS identifier

The three most commonly used identifier is excel, xls, xlsx.

  • unix system: xls to read the file (expand name .xls); xlsx to read the file (expand name .xlsx)
  • windows system: xls, xlsx usage with unix, and more excel identifiers can read all types of excel file

Is the need to distinguish between, excel identifier uses a different technique to read, so results may vary. By default, xls, xlsx excel compared to the identifier will see more rows of data to determine the type of column.

Optional statement

If the file has multiple worksheets, you can use  SHEET  statement to be read to specify the worksheet.

语法:sheet = "sheet-name" ;

If you want to read a particular worksheet cell can  range  specify a region. The region may be a region name (if defined), or may be mounted in the following manner to specify the upper left and lower right cell where the prefetch. a

语法:range = "sheet-name$UL:LR" ;

By default, the first row of the spreadsheet import using the procedure as a variable name. If you do not want to do this, you can add to the process  GETNAMES  statement (excel identifier only), SAS will these variables named F1, F2 and so on.

Syntax: getnames = no;

When using excel identifier, if there is a value and a character value contains. By default, the value will be converted to missing values. To read the value to the missing values instead of the character type, can be used  MIXED  statement.

Syntax: mixed = yes;

proc import datafile = 'D:\code\test.csv' dbms = xls out = music replace;
run;

Guess you like

Origin www.cnblogs.com/shenzhendaiyun/p/12143796.html