Showing posts with label SAS BASE AND ADVANCE. Show all posts
Showing posts with label SAS BASE AND ADVANCE. Show all posts

How To Reverse The Order of Observations In SAS Dataset - ReadingObservations From Backward / Bottom In SAS

Hi,

As we all know that SAS processes the observation from dataset from top to bottom.

Suppose we have a situation where we want to process the bottom observation first from SAS dataset. We can not change the basic property of SAS system but we can change our SAS Dataset.

Which means, here we are changing the order of observations in SAS dataset. Our last observation would be first and the first one would get changed into last. In Simple words, just to reverse the order of observation of sas dataset.

Support we have a dataset, Named as DSN as follows :
                                                           Data DSN;
                                                           Input Name $7.;
                                                           Cards;
                                                           Alfred
                                                           Barbara
                                                           Carol
                                                           Jane
                                                           Jeffrey
                                                           Louise
                                                           Philip
                                                           Robert
                                                           Thomas
                                                           William
                                                           Run;


  Output would be as :

Here we would discuss the two ways to perform our task:

1. Just apply an index with observations and then sort the data in descending order.

                                            DATA DSN;
                                            SET DSN;
                                            INX =_N_ ;
                                            Run;

                                            PROC SORT DATA=DSN OUT=DSN_REVR (KEEP=NAME) ;
                                            BY DESCENDING INX ;
                                            RUN;



 The output would be as :


2.  We can get the desired output by using data step only as well, with the help of NOBS and POINT

                                                           DATA DSN_REVR;
                                                           Do U=NOBS TO 1 by -1;
                                                           SET DSN NOBS=NOBS POINT= U;
                                                           OUTPUT;
                                                           END;
                                                           STOP;
                                                           RUN;

Types Of Error In SAS : Syntax Error, Execution Time Error, Data Error,Semantic Error

Many of us are familiar with Errors in SAS and most of the time we have seen the classification of errors in SAS log.

As per the log classification in SAS, There are four type of errors in SAS :

1. SYNTAX ERROR      2. EXECUTION TIME ERROR    3. DATA ERROR     4. SEMANTIC ERROR

1. SYNTAX ERROR : We can have such types of errors whenever our programming statements or codes does not follow the SAS language coding rules. SAS detects SYNTAX Error at COMPILE TIME / STAGE. Syntax errors could be due to the following reasons :

  • Any keyword which is not spelled correctly (Misspelled keyword)

  • Missing or Invalid punctuation

  • Invalid statements or data set options

Quotations marks not used properly (Unmatched)

2. EXECUTION TIME ERROR : Whenever SAS executes a program which processes data, during the processing of data value if any error occurs that is known as EXECUTION TIME ERROR. Most of the execution time errors just gives warning messages or notes in SAS log but These errors allow the program to continue the execution of data. We can identify execution time error usually by location which would be given as line and column numbers in a SAS note or SAS error message. Execution time error could be due to following reasons:


  • Any mathematical operation which is not legal ( division by zero )

  • Any argument to function which is not legal

  • For BY group processing, when observations are not in proper order

  • While referring to a member of an array which does not exist

  • Open and close error (for brackets and inverted commas) on SAS data sets and other files like INFILE

  • Any INPUT statements which do not match with the cards / datalines 

3. DATA ERROR : We can have such type of errors in SAS, whenever any data values are not as per the SAS statement which we have specified in our SAS program. Suppose we have defined a variable as a numeric but we are passing some data values which are character then SAS gives an error that would be known as DATA ERROR. Data errors occurs during the program execution but these errors allow the program to continue the execution of data and does the following things:

  • It prints the obs under the rule line

  • In the SAS log, It writes an invalid data notes with line number

  • It sets the automatic variable _ERROR_ to for current observation

  • In SAS log, it prints the input line and column number which contain invalid data

4. SEMANTIC ERRORS : We can have such type of error in SAS, whenever our programming statements or codes are up to the mark means any SAS statement is correct but any element is not valid for that specific usage. SAS detects SEMANTIC ERRORS at COMPILE TIME / STAGE. Whenever SAS finds any semantic error in program SAS goes for syntax check mode. Semantic errors could be due to the following reasons :

  • Defining or using a numeric variable where only a character variable is applicable

  • For Array, when we use any illegal reference for it

  • Whenever we do not specify correct number of arguments  for any SAS Functions

Ex:  Suppose we are using a libname for a dataset without assigning it prior, for semantic error, libname statement is valid but as it is not specified previously so it would through an error.

Why We Use FORCE Option With PROC APPEND In SAS To Upload Data To DataWarehouse

Here we are going to discuss use of ‘FORCE’ option in PROC APPEND.

 FORCE option: As per its name, it forces PROC APPEND to concatenate or add or append the data sets in some conditions in which the append procedure would normally fails like: when data sets contains different variables, formats, Lengths and labels.

 PROC APPEND without FORCE option (Using different variables in datasets):

 Suppose we have two datasets named as Primary and Secondary.

                        Primary Dataset – 3 Variables (X, Y,Z ) – 252000 observations

                       Secondary Dataset – 2 Variables (X, Y) -  48000 observations

 Now we run the following code:

         Proc Append Base=Primary Data=Secondary;

        Quit;

 We would get error due to non matching variables in Datasets. Error would be thrown only if Base data set would have different rather than secondary dataset.


Case: 1:-

Now if we use FORCE option then it will force to run PROC APPEND and FORCE would drop or truncate the variable as per the Base dataset (Primary).

Proc Append Base=Primary Data=Secondary FORCE;

Quit;






Data would be added to the primary dataset after truncating or dropping the extra variable in secondary dataset as per primary dataset.

Case: 2:- What if our Secondary dataset would have fewer variables than Primary dataset?

 FORCE option would force to run PROC APPEND and it will assign missing values for the missing variable’s observation in appended dataset from where secondary dataset have values.

                    Primary dataset – 3 variables (X, Y, Z) – 252000 observations

Secondary dataset – 2 Variables (X, Y) – 48000 observations

Code:

 Proc Append Base=Primary Data=Secondary FORCE;

Quit;

Log:

Result:

FORCE option in PROC APPEND has concatenated both dataset and assigned missing values to missing variables observation in secondary data set with respect to primary data set.

We are familiar with PROC APPEND in SAS to upload data to the data warehouse and it’s attributes, Kindly refer to : Difference Between Set Statement And Proc Append In SAS For Appending Data

Difference Between Set Statement And Proc Append In SAS For Appending Data

Hi,

As we all know that there are three ways to upload data into the Data Warehouse:

Append – Can say :Append to existing

  1. Replace

  2. Update/ Insert

Here, we are just going to explain one way only named as APPEND

What append means: We can say that, append is a process in which data would be added in to a primary table from last observation (from the bottom) from secondary table.

Here we are going to see the difference between two ways of appending the tables in Data warehouse and we would see that which one (Data Step or Proc Step) is more efficient.

Two ways to append the data are:

  1. Set Statement ( In Data Step)

  2. Proc Append ( In Proc Step)

Suppose we have two Data sets named as Primary and Secondary both have three variables and 252000,48000 observations respectively.

Dataset Primary – 3 Variables (X, Y, Z) – 252000 Observations

Dataset Secondary – 3 Variables (X, Y, Z) – 48000 Observations

Just Run a small piece of code:

Data  Set_Append;

Set Primary Secondary;

Run;


Combined dataset SET_APPEND would have 300000 observations. If we see the log then we would get to know that SET Statements read both the data set. It means SAS processes the both data set.  Log is displaying the CPU timing and Real timings which are 0.17 and 0.18 seconds respectively.

Now try to run a small piece of code again from SAS procedure named as PROC APPEND:

Proc Append Base=Practice Data=Secondary force;

Quit;


Now Primary dataset would have 300000 observations and as per log, Proc append is reading only secondary dataset, it means it is we have saved time from SAS which was in to read primary dataset. Log is displaying this information is clearly that CPU timing and Real timings which are 0.01 and 0.04 seconds respectively.

Some useful differences between Proc Append and Data Step SET Statement while using as Load Style APPEND for data warehouse:

  • Proc Append is faster than data step SET Statement

  • We can use proc append for only two tables or datasets

  • In Data step, Set statement, we can merge any number of tables or datasets

  • Proc Append uses formats, Informats and Labels from BASE= dataset

  • Set Statement uses defined formats, informats and labels explicitly

  • For Set Statement, if same variable is having different length in two or more datasets, then length would be defined as per the first dataset in SET statement

  • Proc Append, looks for the FORCE option to concatenate and, if length of the variable does not match with primary dataset or table

For description related to FORCE option in PROC APPEND, Kindly refer to:
Why We Use FORCE Option With PROC APPEND In SAS To Upload Data To DataWarehouse

SAS ERROR Library JANUARY Is Not In A Valid Format For Access MethodRANDOM

Hi,

It is a very common error, whenever we try to assign a libref to the LIBNAME function.

Suppose we try to run the following code in windows environment :

Libname January "C:\Users\Uma\Desktop\blog data\1.txt";

and then we would get the following error in SAS log :

                    ERROR: Library JANUARY is not in a valid format for access method RANDOM.

                    ERROR: Error in the LIBNAME statement.

I am not going to deal with the more technical stuff for this. 

Just try to understand the basic job of LIBNAME statement. It's primary functionality is to refer a library or physical location. We can call it here as folder.

 So on the above example, we have given path for the specific file not for folder.

 Remember, whenever you are going to use LIBNAME just give the folder path ( Window environment) not path of any specific file.

 In short : Libname is to refer the folder not file (Windows environment)

 Here we go with correct one :

                                       Libname January "C:\Users\Uma\Desktop\blog data";


Output Column For Number Of Duplicate Rows In SAS

Suppose we have a table or SAS data set that contains duplicate rows/ observation.

We just want to calculate / count the number of duplicate rows from that table / SAS data set .

It would be great if we can generate an output column which could show that how many times each row occurs.

Example : 

Suppose we have a table / SAS data set that contain two variable / column known as last name (Lname) and first name (Fname) showing as :

                                                   Data DSN;

                                                  input Fname $ 1-7 Lname $ 8-15 ;

                                                  Cards;

                                                  Rebecca Smith

                                                  Kathy   John

                                                  Rebecca Smith

                                                  Tom     Andrew

                                                  Reed    Samuel

                                                  Rebecca Smith

                                                  Kathy   John

                                                  Reed    Samuel

                                                  Davis   Kerry

                                                  ;

                                                  Run;

The output would be like that :


To generate the number of duplicate column from the table :

                                                    Proc SQL;

                                                   Select *, count (*) as count 

                                                   From DSN

                                                   Group by Fname, Lname 

                                                   Having count (*) > 1;

                                                   Quit;


and the result would be as :


* DSN is the name of the SAS data set.

SAS Default Sample Data Sets Library With Proc Datasets procedure

Some useful codes for Proc datasets procedure:-

1. To get the default SAS Datasets or Sample library :

 Proc datasets library = Sampsio;

run;



2. To copy an entire library to a specific destination in SAS :

Proc datasets library = Source;

Copy out = Destination;

run;



3. To copy a dataset from one library to another library in SAS :

Proc Copy in = Practice  out = Production;

select DSN;

Run;

* Dataset DSN has been copied to Production library from practice library.



4. Using Datasets Procedure to modify the variable name of existing dataset:

Proc Datasets library = Practice;

Modify DSN;

Rename Emp=Employee;

Quit;

* Variable name EMP has been modified as Employee from Practice library.



5. To delete as SAS library:

Proc Datasets library = Libraryname Kill;

Quit;

* kill option deletes all the members from the library.



6. To delete a SAS Dataset from a SAS library:

Proc Datasets library = Libraryname  nolist;

Delete DSN;

Quit;

* Dataset DSN has been deleted. Nolist option to suppress the printing of the directory of SAS files in the SAS log or ODS output.



7. To change the name of a SAS Dataset:

Proc Datasets library = Practice nolist;

Change Learn=Earn;

Quit;

* Data set Learn has been renamed as Earn.

Change Numeric Values ( 1,5,100...) Into Alphabetic Values ( One, Five,Hundred ...) In SAS

Hi,

Most of the time we stuck with the situation where we need to change Numeric values into Alphabetic.

Suppose we want to convert some numeric values like 1 into one, 5 into five, 100 into hundred and any value.... and even 0 into zero.

Here we go :

                                                             Data DSN;

                                                             input Variable $ Number ;

                                                             Alphabetic=put(number,words30.);

                                                             cards;

                                                             A 0

                                                             B 5

                                                             C 49

                                                             D 100

                                                             E 499

                                                             F 67

                                                             ;

                                                             run;


And the output would be as you need :


In case of, if your value is big like 123456789, need not to worry, just increase the length of words argument.

Example :                    Alphabetic = put (Number,words75.);

Difference Between SAS SUM Function And Using '+' Operator In SAS

Hi All,

Operators :   For any type of calculation, we all are much familiar with Division (/), Multiplication (*), Addition (+) and Substraction (-) which are known as operators. Whenever we are in need to do some calculation in SAS, we use operators. Operators are to do indicated operation between SAS variables or constant values.

Sum Function in SAS :- It returns the sum of non missing and missing arguments.

Ex:          Total = Sum (U,M,A);

Total =  Sum (of  U1 - U10) ;

Total = Sum ( U M A );

"+" Operator in SAS :- It returns a missing value if any of the values (arguments ) are missing.

Difference between SAS Procedure and SAS function

  •  SAS functions would be in need for argument values to be supplied across an observation in SAS dataset.

  •  SAS functions are already written ( pre-written) expressions which gives programming shortcuts for many manipulation and calculation of data

  •  SAS functions are for normal (common ) mathematical operations such as square root, natural log and many more....

  •  SAS Procedures would be in need for one argument value per observation in SAS dataset.

How To Handle Special Missing Values In SAS

Hi All,

 Today we are going to discuss, how to handle missing values in SAS. Yes, I know, you are going to say that you know this thing very well. It’s not about the normal missing values. It’s for SPECIAL MISSING VALUES.

 What is SPECIAL in Missing values:

Suppose I am the owner of a medical shop and I need to enter the name of the medicines which are not available. I am going to take ‘i’ for fever medicine and ‘-‘for cold.

Now I have two type of missing values ‘i’ and ‘-‘. I think you got my point for special missing values.

 If not, then another example is going on:

Suppose in an organization an employee is absent on a day and organization is noting down this one with a notation ‘A’. Some time it happens that employee is in office but he forgot to swipe his details so the system would reflect absent as per the process. But for this type of missing information of absent, organization is having notation like ‘<’.

 Finally you got the point for SPECIAL MISSING VALUES.

 The special missing value is a type of numeric missing value that enables us to show different categories of missing data by using the letters A to Z (A-Z) or an underscore in the data.

 To deal with the special missing values in SAS we have MISSING Statement. We just need to assign all special missing values in Missing Statement;

 Here we go with the example:

Data DSN;

Input id x;

Missing i a _;

Datalines;

1 i

2 0

3 a

4 155

5 _

6 .

7 -24546

8 548

;

Run;


And the output would be like this :

* Here we have Special Missing values ‘I’, ‘a’ and ‘_’.

* DSN is the name of the dataset.

 The order of special missing values can be understand like this: (_) < (.) < (A) < (Z) < (-24546) < (0) < (155).

 *(-24546) is a negative integer and (155) is positive integer.

 You can check the all special values, if it is working correctly in the following example: (Try by yourself just giving you code)

Data calc;

Input x1 x2 x3; (Missing statement is unavailable)

Datalines;

1 2 a

3 2 i

3 1 x

1 1 1

2 2 2

;

Run;




Data Test;

Set calc;

Missing a i x;

Total = x1+x2+x3;

Sumfn= sum(of x1-x3);

Run;




Data exp;

Missing a;

X1 = ._;

X2 = 5;

X3 = .a;

Sum = x1 + x2 + x3;

Sumfn = sum(of x1,x2,x3);

Run;

Note=> Remember if we are assigning a missing value in an expression or in any assignment statement, a period (.) must be used before the special missing value or an underscore otherwise there will be an error in SAS log i.e. "NOTE: Variable _ is uninitialized."  And same happens with a character missing value as well.

Column Pointer Control in SAS : @, +N,/ and #N

Hi,

To get the control while reading external file (with infile statement) and with cards/dataline statement :

@n : Moves the pointer to the nth column in the input buffer

+n : Moves the pointer forward "n" column in the input buffer

/  : Moves the pointer to the next line in the input buffer

#n  : Moves the pointer to the nth line in the input buffer

Example :

Data DSN;

input ID 1-4 // openweight 1-3 closeweight 5-7;

Cards;

1023 David Shaw

Red

189 167

1049 Kathy Jones

yellow

145 124

;

run;






* For others please try yourself and put the example into the comment..

Difference Between Run Statement And Quit Statement in SAS

Hi,

In SAS, Run Statement and Quit statement could be the formally last word in Data step or Proc Step but both have lots of differences. I am writing just few of them.



RUN Statement : -

1. It executes all previously submitted SAS Statements.

2. It executes the procedure but not end it.

3. For Run statement or for run group execution we need to submit either a RUN cancel or a Quit Statement.



QUIT Statement :-

1. It executes all previously submitted SAS Statements as well as it marks the end of the procedure.

2. Quit statement allow us to use the same procedure continuously without executing or submitting another procedure.

3. It is to run group processing which enables us to submit certain procedures with a RUN statement.

Library Concatenation in SAS : How To Refer Multiple SAS Libraries To A Single Libref

Whenever we want to access more than one SAS library in a data set by using only single Libref, SAS library combination or concatenation concept comes into the picture.

Combination of SAS library is the logical combining of two or more SAS Libraries. By this, we can access several libraries with one libref.

As we are already familiar that we can combine / concatenate more than two libraries by specifying their own libref or physical location name in LIBNAME statement.

Suppose we have some libraries at physical location like:

Libname  JAN “C:\Users\Uma\Desktop\blog data”;

Libname  FEB “C:\Users\Uma\Desktop\blog data\Functions”;

Libname  MAR “C:\Users\Uma\Desktop\blog data\Pictures”;

Libname  APR “C:\Users\Uma\Desktop\Template Code”;

Combination of more than two libraries would be as following:

Libname YEAR (JAN FEB MAR APR);

Or

Libname YEAR (“Path1” “Path2” “Path3” “Path4”);







Even we can go like this as well

 Libname Total (“C:\Users\Uma\Desktop\Template Code\Backup Template” FEB MAR APR);



We can use this assigned libref with another LIBNAME as well as follows


 LIBNAME COMPLETE (YEAR “Path5”);



  •  If we don’t enclosed the physical name in single or double quotation marks  then SAS would look for a previously mentioned libref with the same name

To Calculate The Size Of SAS DataSet BY Proc Contents

Hi,

 For most of the cases to optimize the system, we would be in need of the size of the data set, to set some SAS System options like : SORTSIZE, MEMSIZE, REALMEMSIZE etc.

 To Calculate size of any SAS dataset:-

 For example we want to calculate the size of a data set named as "Calculate" which one is in library named as "Base". Just create the data set that contains one observation and all the number of variables we are in need.

                                                        Data base.Calculate;

                                                        input name $18. Age 2. Salary 6. ;

                                                        Cards;

                                                        Uma Shanker Saini 30 300000

                                                         ;

                                                         run;

                                                         Proc print;

                                                         run;

 Now run the CONTENTS procedure with the data set "Calculate".

                                                      Proc contents data=Base.Calculate;

                                                      Run;

Calculate

Calculate1

The size of the Calculate data set would depend on the data set page size and the total number of observation in  data set.

Formula to calculate :-

 Number of data pages =  1 + (floor( observations / Max observation per page))

Size = 256 + ( Data set page size * number of data pages)

 * floor is a function which is to round the value

 Now as per our example :

 Number of data pages = 1 + (floor(1/101))

 Data set size = 256 + 4096*1 = 4352

 Thus the Calculate data set uses 4,352 bytes of storage space.

How To Reduce Entries In SAS Log

Hi,

Try to use some SAS options - including macro and system (hardware related) to decrease the size of your log.

NOMPRINT       -Removes SAS statements that are generated by macro execution

ERROR=1         -Minimize the number of error to be shown in log to one by default it is 20

NOECHOAUTO  -No autoexec code in Log

MSGLEVEL     - Set to N - It will display notes, warning and errors in log

MSGLEVEL     - Set to I - It will display additional notes like index, merge, sort utility and all

NONOTES      - Suppress the notes in log

NOSOURCE /NOSOURCE2     - Suppress the primary and secondary source information in SAS log

NODTRESET     - Suppress the date and time in the SAS Log

NOWARNING     - Suppress the warning messages in the SAS Log

  •  You can try more options like : NOMTRACE, NOMLOGIC, NOMACROGEN, NOSYMBOLGEN, NOCPUID, NOECHOAUTO,NOOVP, Page No=min

  •  You can also try to run Proc options first the search for all the options which are containing log and try to use NO with that options (use only if exists)


Kindly use as per your convenient because of use of every options suppresses the different things in log.

 

SDLC Phases And Documents Into SDLC 2.0

Phase                                                                     Documents

1.      Project Initiation --------------------------    Project Charter

2. (a) Plan and Analysis -------------------------    Project Execution Plan

2. (b) Plan and Analysis -------------------------    Requirement Document

2. (c) Plan and Analysis -------------------------    Test Strategy

3. (a) Design ------------------------------------    Solution Architecture Document

3. (b) Design ------------------------------------    Security Interaction Document

3. (c) Design ------------------------------------    Detailed Design Document

4. (a) Build --------------------------------------   Component Test Result  (Quality)

4. (b) Build --------------------------------------   Assembly Test Result (Quality)

5. (a) Test ---------------------------------------   System Integration Test Result Report (Quality)

5. (b) Test ---------------------------------------   User Acceptance Test (Quality)

6. Release and Deploy ---------------------------   Project Performance Report

 

 

Proc SQL With Where Clause In SAS

We can have a look into WHERE clause in SQL Procedure. It helps us to dig the specific data but it could be faster and useful if we use WHERE Clause with operators.

Suppose we have a SAS dataset and variable of it as follows: Date, Name,LName Address, State

e.g: Name =SHANKER,  LName=SAINI

To select data from any range we can use BETWEEN – AND operator with Where clause in PROC SQL.

  • Syntax: Where Date between ‘01Jul2014’d AND ‘28Jul2014’d


We can use IN operator to select values from list:

  • Syntax: WHERE State in (‘MH’,’UP’,’PB’)


We can use MISSING operator to select missing values from data:

  • Syntax: Where State is MISSING


We can use CONTAINS operator to select a string by using its letters only:

  • Syntax: Where Name CONTAINS ‘KER’


 We can use LIKE operator with WHERE Clause with PROC SQL to select any pattern:

  • Syntax:  Where name like ’K_R’



  1. We have two wild card operators with WHERE clause ‘_’ (Underscore) and ‘%’ (Percent)

  2. With the Like operator in WHERE Clause , Underscore(_) wild card is for one character and percent ‘%’ sign is for more than one character missing in string



  • Syntax : Where Name like ‘%ER’


We can use (*) to select the data with spelling variation or for values that sound like specified values like:   Syntax : Where LName=*’SAINI’

We can use a column reference / alias in WHERE Clause to refer to a calculated value (We have to use CALCULATED keyword in this case).

 PROC SQL;

Select Var1, Var2, Var3 + Var4 as Total, CALCULATED Total/4 as Quarter from DSN; QUIT;

Or

PROC SQL;

Select Var1, Var2, Var3 + Var4 as Total from DSN

Where CALCULATER Total  > 500;      or      Where Var3 + Var4 > 500 ;  QUIT;

SAS SORTSIZE Option For Large Amount Data Files Of SAS Data Sets

Hi,

Suppose we are dealing with a file (.txt) which is around 500 mb and we need to sort the data with the help of Proc Sort. if we directly sort the data then system would not be able to do it. It would get hang and all.

To deal with such type of big data, we need to check some SAS System options like : SORTSIZE (specific to proc sort), MEMSIZE, REALMEMSIZE.

1. The MEMSIZE option is set defaults to 96 MB and SORTSIZE is set to default to 80 MB for Unix/Linux servers.

It is not good to set the MEMSIZE option to zero on Unix and Linux servers.

2. On Windowing environment, MEMSIZE option is set to zero by default and for SORTSIZE it is 64 MB.

3. SORTSIZE option creates a temporary utility file in sas work library, in which it store the data

4. The SORTSIZE sas option is similar to the REALMEMSIZE sas system option

5. SORTSIZE sas system option only effect the SORT Procedure while REALMEMSIZE sas system option effects multiple procedures.

SORTSIZE = option ;

Proc Sort statement supports the sortsize = option , which set the limit of the amount of memory available for proc sort to use.

To set sortsize option:-  Here "n" is defined as a real number only

n         -     Amount of memory in bytes

nK      -     Amount of memory in kilobytes

nM      -     Amount of memory in megabytes

nG       -     Amount of memory in Gigabytes

Min     -     Specify the minimum amount of memory available

Max    -     Specify the maximum amount of memory available

 

* SORTSIZE = value can increase or decrease CPU and I/O resource utilization

* If our machine has 14 MB of physical memory and we are sorting large data sets, setting SORTSIZE option between 4 MB to 10 MB may improve your system performance.

* We always need free disk space that should be equals to three to four time of large data sets. Suppose our data set requires 2 MB of disk space, then we would be in need 6 MB to 8 MB of disk space to sort the data

 

Finding Max Observation By Data Step Only In SAS

Hi All,

Suppose we have a data set like below:

EmpID      EmpSal     EmpName

E001          5000          A

E002          7500          B

E003          2500          C

E004          9800          D

E005          6100          E

 

I am looking for the maximum salaried EmpID / EmpName or whatever which should contain maximum value from a variable.

then you can try like it, without using any procedures and options:

 

data want;

   set have nobs=_nobs_;

   if EmpSal > max_EmpSal then do;

     max_EmpSal = EmpSal;

     max_EmpID = EmpID;

     max_EmpName = EmpName;

   end;

   retain max_:;

   keep max_:;

   if _n_ = _nobs_;

run;

 

SAS PDV - Program Data Vector In SAS

Hi,

PDV (Program Data Vector) : The information about each of the variables is stored in a reserved area of memory called PDV.

SAS Processes data steps in two stages : (1) Compile Stage  (2) Execution Stage

In Compile stage SAS does some housekeeping jobs like to prepare an area to store the sas dataset, then to check input file ( infile statement) to fix various attribute of input file. Then to put all the information at a place in memory called as INPUT BUFFER (where it place each record of data as it is read from the input file).

SAS checks for each variable is character or numeric and the storage length of each variable, this information is called the descriptor portion of the data set.

Descriptor Portion contains : Name of data set, Date and time that the data set was created , Number of observations and the number of variables (It contains attribute information for each variable in the data set )

SAS does following action during compile stage :

(a)  Syntax Scan

(b)  Sas Source code translation to machine language

(c)  Definition of input and output files

(d)  Create input buffer, PDV and data set descriptor information

(e)  Setting the variable attribute for output sas data set

(f)  Capture of variables to be initialized to missing.

 

Regards

Uma Shanker Saini