The script uses a DATA STEP to define the structure of the 'ratings' dataset with 'stars' (numeric) and 'rating' (character) variables. The data is then inserted directly into the dataset via the DATALINES statement, using commas as delimiters (DSD - Delimited, Separated, Data).
Data Analysis
Type : CREATION_INTERNE
Data is created directly within the SAS script using the DATALINES statement. It does not come from an external source or from default SAS libraries like SASHELP.
1 Code Block
DATA STEP Data
Explanation : This code block uses a DATA STEP to create a temporary SAS dataset named 'ratings'. The 'length' statement defines the types and lengths of the 'stars' (8-byte numeric) and 'rating' (15-character) variables. 'infile datalines dsd;' indicates that the raw data is provided within the script itself (datalines) and that the delimiter is a comma, also handling quotes. 'input stars rating;' associates the read data with the variables. The lines following 'datalines;' are the inserted observations.
Copied!
data ratings;
length stars 8 rating $ 15;
infile datalines dsd;
input stars rating;
datalines;
1, Hated it
2, Didn't like it
3, Liked it
4, Really liked it
5, Loved it
;
1
DATA ratings;
2
LENGTH stars 8 rating $ 15;
3
INFILEDATALINES dsd;
4
INPUT stars rating;
5
DATALINES;
6
1, Hated it
7
2, Didn't like it
8
3, Liked it
9
4, Really liked it
10
5, Loved it
11
;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.