Question-: How can you define character variable and upto what length you can have character variable?
Answer: To define a character variable we need to add $ sign after the variable name and we can have character variable upto 32767 bytes long. To specify the length we have to supply an informat or use the column numbers.
Question-: How do you specify that variables can be printed or displayed in specific format?
Answer: You can use two attributes format and label which can define how the variables values can be printed and displayed.
Question-: What all are the possible ways from which SAS can read the data to create SAS Dataset?
Answer: You can use following 4 ways by which you can specify the location of the data for creating a new Dataset - Stream: You can provide raw data inline using the DATALINES statement. In this case DATALINES statement and actual data must occur last in the DATA step statements. As you can see in below example
- FILE: If data is in the file then you have to use INFILE statement. See example below
- SAS Dataset: You can use existing SAS DATASET to create new DATASET. You can use following statement and with the existing DATASET o SET , MERGE, MODIFY, UPDATE In the following example you are creating new dataset named he_data_new from existing dataset he_data and in the new data set you are adding one additional variable “FEE� in each observation.
- DBMS file: You can create Dataset from the Database management System as well. In this case you have to use SAS/ACCESS software to bring this data into a SAS data set. You can make the connection with the Oracle or any other DBMS using libname statement and helib is a library reference, you can create a new SAS Dataset named he_data from the learner table in the database.
Question-: What is the “Fileref� , when you should use and what all are the advantages?
Answer: If you wanted to refer to external file then you can use the fileref for that external file. This is you can consider as a shorthand for referring external file in your SAS program. Once fileref is created you can use it in your program like in the FILE or INFILE statement. Advantages: - If you are referring the same file at multiple places in a program and file name changes for the external file then you don’t have to make changes to many places. Only once place you change it wherever fileref is created. As you can see in below example
“heref� is a fileref which represent external file at 'c:/Users/hadoopexam/he_data.csv'. And same fileref (heref) you can use in your infile statement.