Friday, April 1, 2016

Creating a Single Obs from Multiple Records In Flat Files

Creating a Single Obs from Multiple Records

Description:  To Create a Single Obs from Multiple Records there are two types of line pointer controls

  • The forward slash (/) specifies a line location that is relative to current one
  • The #n specifies the absolute number of the line to which you want to move the pointer
  1. The Forward Slash (/) Line Pointer Control (Reading Multiple Records Sequentially)
In this Method we can read records only in Sequence in which they are present in flat file
  1. The #n Line Pointer Control (Reading Multiple Records Non-Sequentially)
On the other hand in this Method we can read records in any Sequence as per Desired

In flat file mohit.txt FName and LName are in first record, followed by City and State in second record, Organisation and Id in third record.

NOTE :Raw Data file must contain the same number of records for each Obs .Suppose if we are having only two records for the the Second member then it reads the first record of third member as third record of second member which results in ambiguity in output.


Flat Files


mohit.txt

















EXAMPLE (Code)



OUTPUT

EMPLOYEE (READING MULTIPLE RECORD SEQUENTIALLY)

EMPLOYEE1 (READING MULTIPLE RECORD NON-SEQUENTIALLY)





Got Questions ? Pls put them in Comment Box........












Sunday, March 27, 2016

NMISS

SAS Function to handle MISSING data -  NMISS

Syntax : NMISS(argument,...argument-n)


Description:  The NMISS() function returns the number of missing values in the specified list of numeric variables. 

Note:The NMISS() function converts any character values to numeric before assessing if the argument value is missing.

MISSING function vs NMISS function NMISS works with multiple numeric values, whereas MISSING works with only one value that can be either numeric or character

Examplecount the number of the variables X, Y, and Z which have missing values:
 Count=nmiss(x,y,z)
 Count=nmiss(of x y z)


Code:



Result:




Got Questions? Please put them in comment box....
Cheers

Wednesday, March 23, 2016

Reading Missing Values In Flat Files

Reading Missing Values In Flat Files

Description: Reading Missing Values at the End of a Record as in mohit.txt  using missover  and
Reading Missing Values at the Beginning or Middle of a Record as in rohit .txt using dsd .


NOTE : By default delimiter is space " " so no need of giving it with missover but on the other hand with dsd by default delimiter is comma "," so that we  have to give dlm = " " if it is space delimited file

Flat Files
    
mohit.txt
 
rohit.txt
EXAMPLE


OUTPUT

Missover







Dsd






And the LOG Window



Got Questions ? Pls put them in Comment Box........



Tuesday, March 22, 2016

The Missing Function in SAS

The Missing Function in SAS

Syntax for Missing Function :   MISSING(numeric expression|character expression)

DescriptionThe MISSING function checks whether the argument/expression  has a missing value, and returns a numeric result. If the argument/expression does not contain a missing value, SAS returns a value of 0. If the argument/expression  contains a missing value, SAS returns a value of 1. 

Note: The MISSING function checks whether the argument has a missing value but does not change the value of the argument.

Example




Output


And The Log window


Got Questions? Please put them on comment box....

Cheers,

Wednesday, March 2, 2016

SAS Statements: Libname #1.1 Assigning and Deassigning Libraries

* Assigning user defined Library;

Libname am "C:\Users\amit\Desktop";


****************************;

* Deassigning user defined Library;

Libname am clear;