Question-71: What is the use of IMPORT proc?

Answer: IMPORT proc as name suggests, import the data from external data source and writes it to a SAS Data set. Using this you can import both structured and unstructured data. Example files which you can import are

  • Delimited files (Comma, tilde, blank, tab etc.)
  • Excel files
  • JMP 7 files (If using SAS 9.4)

However, be default IMPORT proc assume that first row has the header information. And to guess the correct number of variables, their informats and formats it scans first 20 (which you can change) rows in the file. Internally IMPORT proc create DATA step to read the contents of the file. The generated DATA step code you can see in the log information generated as part of the SAS IMPORT statement.

 

Question-72: What is the use of VALIDMEMNAME= system option?

Answer: Using system option VALIDNAME= we can enhance the rule for having SAS Name datasets like having special character or international character in the SAS Data set name if we use VALIDMEMNAME=EXTEND.

 

Question-73: Can you specify WHERE= data set option while importing csv file using “IMPORT” statement?

Answer: No, when importing delimited, comma separated, or tab-delimited external files we can not use any SAS Data set options like ALTER=, PW=, READ=, WRITE= and WHERE= etc.

 

Question-74: Can you import specific sheet of the excel file as SAS Data set, if yet then how?

Answer: To import the excel data we can use the IMPORT statement and we need to specify DBMS=XLSX. If we want to specify specific sheet from the xlsx then we need to use sheet=<sheet_name> option for example as below.

 

Option validvarname=v7;

Proc import datafile=’c:\Users\HadoopExam\he_learner.xlsx’

                Dbms=XLSX

                Out = work.he_learner

                Sheet=courses

Run;

Here validvarname option helps in converting spaces into underscores, while converting column name to variable name.

 

Question-75: What is the use of SAS System option “OBS=”?

Answer: Using the SAS OBS= option you can specify how many observations to read. Suppose OBS=5 then it read 5 observations. If you want to read entire or all observations then you have to specify OBS=max.