Posts

Showing posts with the label delimiters

SAS Interview Questions: Base SAS

Very Basic: What SAS statements would you code to read an external raw data file into a DATA step? You would use the INFILE statement to specify the location of the external raw data file, and the INPUT statement to read in the data into the variables in a SAS dataset. How do you read in the variables that you need? You use the INPUT statement with specific column pointers, such as @5 or 12-17 , to define where each variable is located in the raw data file. Are you familiar with special input delimiters? How are they used? Yes, special input delimiters like DLM and DSD are used to specify how fields are separated in the data. They are included in the INFILE statement. For example, the DLM option can be used to specify a comma as a delimiter for CSV files. The DSD option is used for comma-separated values (CSV) files and treats consecutive delimiters as missing values and ignores delimiters enclosed in quotation marks. If reading a variable-length file with fixed inp...

HOW TO USE THE SCAN FUNCTION:

USING THE SCAN FUNCTION: SCAN (string,n,delimiters): returns the nth word from the character string string, where words are delimited by the characters in delimiters.  It is used to extract words from a  character value when the relative order of words is known, but their starting positions are not. NewVar= SCAN (string,n<, delimiters >); -returns the nth ‘word’ in the string   When the SCAN function is used: ô€‚ƒ the length of the created variable is 200 bytes if it is not previously defined with a LENGTH statement ô€‚ƒ delimiters before the first word have no effect When the SCAN function is used, ô€‚ƒ any character or set of characters can serve as delimiters Points to remember while using SCAN Function: ô€‚ƒ a missing value is returned if there are fewer than n words in string ô€‚ƒ two or more contiguous delimiters are treated as a single delimiter ô€‚ƒ if  n is negative, SCAN selects the word in the character string starting from the end of stri...