SAS Data Set Operations

SAS – Read Raw Data

SAS can read information from different sources which incorporates numerous record groups. The record positions utilized as a part of SAS condition is talked about underneath.

  • ASCII(Text) Data Set
  • Delimited Data
  • Excel Data
  • Hierarchical Data

Reading ASCII(Text) Data Set

These are the records which contain the information on content configuration. The information is generally delimited by a space, however, there can be diverse sorts of delimiters additionally which SAS can deal with. How about we consider an ASCII record containing the representative information. We read this document utilizing the Infile proclamation accessible in SAS.

Reading Delimited Data

These are the information documents in which the segment esteems are isolated by a delimiting character like a comma or pipeline and so forth. For this situation, we utilize the dlmoption in the infile explanation.

Reading Excel Data

SAS can specifically read an exceed expectations record utilizing the import office. As found in the section SAS informational indexes, it can deal with a wide assortment of document writes including MS exceed expectations. Accepting the record emp.xls is accessible locally in the SAS condition.

Reading Hierarchical Files

In these documents, the information is available in a progressive organization. For a given perception there is a header record underneath which numerous detail records are said. The quantity of subtle elements records can differ starting with one perception then onto the next. The following is a representation of a various leveled document.

In the beneath record, the subtle elements of every representative under every division are recorded. The main record is the header record saying the division and the following record few records beginning with DTLS are the points of interest record.

SAS – Write Data Sets

Like perusing datasets, SAS can compose datasets in various organizations. It can compose information from SAS records to an ordinary content document. These records can be perused by other programming programs. SAS utilizes PROC EXPORT to compose informational indexes.


It is a SAS inbuilt technique used to send out the SAS informational collections for composing the information into documents of various arrangements.


The fundamental linguistic structure for composing the system in SAS is:


DATA=libref.SAS data-set (SAS data-set-options)



Following is the depiction of the parameters utilized:

  • SAS data setis the informational collection name which is being sent out. SAS can share the informational indexes from its condition with different applications by making documents which can be perused by various working frameworks. It utilizes the inbuilt EXPORT capacity to out the informational index records in an assortment of arrangements. In this section, we will see the written work of SAS informational collections utilizing proc trade alongside the alternatives dlm and dbms.
  • SAS data-set is utilized to determine a subset of sections to be traded.
  • filename is the name of the record to which the information is built into.
  • identifier is utilized to specify the delimiter that will be built into the record.
  • LABEL choice is utilized to specify the name of the factors kept in touch with the document.

SAS – Concatenate Data Sets

Various SAS informational collections can be connected to give a solitary informational collection utilizing the SET explanation. The aggregate number of perceptions in the linked informational index is the total of the number of perceptions in the first informational collections. The request of perceptions is successive. All perceptions from the main informational collection are trailed by all perceptions from the second informational index, et cetera.

In a perfect world all the joining informational collections have same factors, yet on the off chance that they have a diverse number of factors, at that point in the outcome every one of the factors shows up, with missing qualities for the smaller data set.


The basic Syntax for SET articulation in SAS is:

SET data-set 1 data-set 2 data-set 3…..;

Following is the depiction of the parameters utilized:

  • data-set1,data-set2 are dataset names thought of in a steady progression.


When we have numerous varieties in the informational collections for connection, the aftereffect of factors can contrast yet the aggregate number of perceptions in the linked informational index is dependably the entirety of the perceptions in every datum set. We will consider underneath numerous situations on this variety.

Different number of factors

On the off chance that one of the first informational indexes has more number of factors than another, at that point the informational indexes still get joined however in the littler informational index those factors show up as absent.

Different variable name

In this situation, the informational indexes have the same number of factors yet a variable name varies between them. All things considered, an ordinary connection will create every one of the factors in the outcome set and give missing outcomes for the two factors which contrast. While we may not change the variable name in the first informational indexes we can apply for the RENAME work in the linked informational index we make. That will deliver an indistinguishable outcome from a typical link obviously with one new factor name set up of two distinctive variable names show in the first informational collection.

Different variable lengths

On the off chance that the variable lengths in the two informational collections are not the same as the connected informational index will have values in which a few information is truncated for the variable with a smaller length. It happens if the principal informational index has a smaller length. To understand this we apply the higher length to both the informational collection.

SAS – Merge Data Sets

Numerous SAS informational indexes can be consolidated in light of a particular basic variable to give a solitary informational index. This is finished utilizing the MERGE articulation and BYstatement. The aggregate number of perceptions in the combined informational index is regularly not as much as the total of the number of perceptions in the first informational collections. It is on account of the factors shaping the two informational indexes get converged as one record based when there is a match in the estimation of the normal variable.

There are two Prerequisites for blending informational collections given beneath:

  • input informational indexes must have no less than one basic variable to converge on.
  • input informational collections must be arranged by the regular variable(s) that will be utilized to converge on.


The basic Syntax for MERGE and BY articulation in SAS is:

MERGE Data-Set 1 Data-Set 2

BY Common Variable

Following is the depiction of the parameters utilized:

  • Data-set1, Data-set2 is informational collection names kept in touch within a steady progression.
  • Common Variable is the variable in view of whose coordinating qualities the information collections will be combined.

Missing Values in the Matching Column

There might be situations when a few estimations of the regular variable won’t coordinate between the informational indexes. In such cases, the informational indexes still get consolidated however give missing qualities in the outcome.

Combining just the Matches

To maintain a strategic distance from the missing qualities in the outcome we can consider keeping just the perceptions with coordinated qualities for the normal variable. That is accomplished by utilizing the IN explanation. The union proclamation of the SAS program should be changed.

Subsetting a SAS informational index implies separating a piece of the informational index by choosing a less number of factors or less number of perceptions or both.

SAS – Subsetting Data Sets

While subsetting of factors is finished by utilizing KEEP and DROPstatement, the subsetting of perceptions is finished utilizing DELETE explanation. Likewise, the subsequent information from the subsetting task is held in another informational index which can be utilized for assist examination. Subsetting is predominantly utilized to analyze a piece of the informational index without utilizing those factors or perceptions which may not be important to the investigation.

Subsetting Variables

In this strategy, we remove just a couple of factors from the whole informational collection.


The essential sentence structure for subsetting factors in SAS is:

KEEP var1 var2 … ;

DROP var1 var2 … ;

Following is the portrayal of the parameters utilized:

  • var1 and var2 are the variable names from the informational index which should be kept or dropped.

Subsetting Observations

In this technique, we remove just a couple of perceptions from the whole informational collection.


We utilize PROC FREQ which monitors the perceptions chose for the new informational collection.

The language structure for subsetting perceptions is:

IF Var Condition THEN DELETE ;

Following is the depiction of the parameters utilized:

  • Var is the name of the variable in view of whose esteem the perceptions will be erased utilizing the predefined condition.

SAS – Sort Data Sets

Informational collections in SAS can be arranged on any of the factors exhibit in them. This helps both in information examination and performing different choices like combining and so on. Arranging can occur on any single variable and additionally different factors. The SAS technique used to complete the arranging in SAS informational index is named PROC SORT. The come about subsequent to arranging is put away in another informational index and the first informational index stays unaltered.


The essential language structure for sort task in an informational collection in SAS is:

PROC SORT DATA=original dataset OUT=Sorted dataset;

BY variable name;

Following is the depiction of the parameters utilized:

  • variable name is the segment name on which the arranging happens.
  • Original dataset is the dataset name to be arranged.
  • Sorted dataset is the dataset name after it is arranged.

Switch Sorting

The default arranging choice is in rising request, which implies the perceptions are orchestrated according to the lower to a higher estimation of the arranged variable. Be that as it may, we may likewise need the sort to occur in a climbing request.

Arranging Multiple Variables

Arranging can be connected to numerous factors by utilizing them with the BY articulation. The factors get arranged with a need from left to right.

SAS – Format Data Sets

At times we want to demonstrate the broke down information in a configuration which is not the same as the organization in which it is as of now show in the informational index. For instance, we need to include the dollar sign and two decimal spots to a variable which has value data. Or on the other hand, we might need to demonstrate a content variable, all in capitalized. We can utilize FORMAT to apply the in-fabricated SAS arrangements and PROC FORMAT is to apply client characterized groups. Additionally, a solitary configuration can be connected to different factors.


The fundamental sentence structure for applying in-assembled SAS positions is:

format variable name format name

Following is the depiction of the parameters utilized:

  • variable name is the variable name utilized as a part of the dataset.
  • format name is the information organization to be connected to the variable.


We can likewise utilize PROC FORMAT to organize information. In the beneath illustration, we relegate new qualities to the variable DEPT extending the name of the office.

At the point when the above code is executed, we get the accompanying yield.


SAS offers broad help to the greater part of the well known social databases by utilizing SQL questions inside SAS programs. A large portion of the ANSI SQL language structure is upheld. The system PROC SQL is utilized to process the SQL articulations. This method cannot just give back the aftereffect of a SQL question, it can likewise make SAS tables and factors. The case of every one of these situations is depicted beneath.


The essential linguistic structure for utilizing PROC SQL in SAS is:


SELECT Columns


WHERE Columns

GROUP BY Columns



Following is the depiction of the parameters utilized:

  • The SQL question is composed beneath the PROC SQL proclamation took after by the QUIT articulation.

Beneath we will perceive how this SAS methodology can be utilized for the CRUD (Create, Read, Update and Delete) operations in SQL.

SQL Create Operation

Utilizing SQL we can make new informational collection shape crude information.

SQL Read Operation

The Read activity in SQL includes composing SQL SELECT inquiries to peruse the information from the tables.


The program inquiries the CARS informational index with a where condition. In the outcome, we get just the perception which has make as ‘Audi’ and sort as ‘Games’.

SQL UPDATE Operation

We can refresh the SAS table utilizing the SQL Update explanation

SQL DELETE Operation

The erase task in SQL includes expelling certain qualities from the table utilizing the SQL DELETE articulation.


The yield from a SAS program can be changed over to easier to understand shapes like .html or PDF. This is finished by utilizing the ODS proclamation accessible in SAS. ODS remains for yield conveyance framework. It is generally used to organize the yield information of a SAS program to decent reports which regard take a gander at and get it. That likewise helps to impart the yield to different stages and delicate products. It can likewise consolidate the outcomes from numerous PROC articulations in a single record.


The fundamental punctuation for utilizing the ODS articulation in SAS is:

ODS outputtype

PATH path name

FILE = Filename and Path

STYLE = StyleName


PROC some proc


ODS outputtype CLOSE;

Following is the depiction of the parameters utilized:

  • PATH speaks to the announcement utilized as a part of an instance of HTML yield. In different sorts of yield, we incorporate the way in the filename.
  • Style speaks to one of the inbuilt styles accessible in the SAS condition.

Making HTML Output

We make HTML yield utilizing the ODS HTML proclamation. We make an HTML record in our coveted way. We apply a style accessible in the styles library. We can see the yield document in the said way and we can download it to spare in a situation not quite the same as the SAS condition. It would be ideal if you take note of that we have two proc SQL proclamations and both their yield is caught into a solitary record.

Making PDF Output

We make a PDF record in our coveted way. We apply a style accessible in the styles library. We can see the yield record in a specified way and we can download it to spare in a domain not the same as the SAS condition. If you don’t mind take note of that we have two proc SQL articulations and both their yield is caught in a solitary document.

Making TRF(Word) Output

We make an RTF record in our coveted way. We apply a style accessible in the styles library. We can see the yield record in a specified way and we can download it to spare in a domain not the same as the SAS condition. It would be ideal if you take note of that we have two proc SQL explanations and both their yield is caught into a solitary record.

SAS – Simulations

The Reenactment is a computational procedure that utilizations rehashing calculation on various irregular examples with a specific end goal to gauge a factual amount. Utilizing SAS we can recreate complex information that has determined measurable properties in a true framework. We utilize programming to assemble a model of the framework and numerically create information that you can be utilized for a superior comprehension of the conduct of this present reality framework. Some portion of the specialty of outlining a PC recreation show is choosing which parts of the genuine framework are important to incorporate into the model with the goal that the information produced by the model can be utilized to settle on viable choices. As a result of this multifaceted nature, SAS has a committed programming segment for Simulation.

The SAS programming segment which is utilized as a part of making SAS reproduction is called SAS Simulation Studio. Its graphical UI gives a full arrangement of instruments for building, executing, and investigating the consequences of discrete occasion reenactment models.

Distinctive kinds of factual appropriations on which SAS reproduction can be connected are recorded beneath.


SAS Training in Chennai @ Greens Technology

  • If you are seeking to get a good SAS Training in Chennai, then Greens Technologys should be the first and the foremost option.
  • We are named as the best training institute in Chennai for providing the IT related training. Greens Technologys is already having an eminent name in Chennai for providing the best software courses training.
  • Rated as No.1 Leading SAS Training Institute in Chennai offering classroom training, practical training, and online training.
  • World-class top of the line SAS Training in Chennai for Base SAS, Advanced SAS and Clinical SAS with Certification and Placements. We offer genuine SAS Course in Chennai. For points of interest call us at 89399-15577 or stroll into our SAS Training Institutes in Chennai situated in Adyar, Velachery or OMR.