Raw data is included directly in the SAS script via DATALINES blocks for the 'stat.Punjab' and 'stat.Punjab1' datasets.
1 Code Block
DATA STEP Data
Explanation : This block defines the SAS library 'stat' and then creates a permanent SAS dataset 'stat.Punjab'. It reads raw data by columns (INPUT) defining 'Town' as character, 'Zip', 'day', 'month', 'year', 'temperature' as numeric. Data is provided inline via DATALINES.
Copied!
LIBNAME stat '/home/u4029796/SASClass';
DATA stat.Punjab;
INPUT Town $ 1-10 Zip 12-17 day 20-21 month 23-24
year 26-29 temperature 32-33;
DATALINES;
Ludhiana 141101 02 01 2015 52
Amritsar 142001 13 06 2015 28
Bathinda 152875 05 8 2016 43
Patiala 187525 25 07 2015 20
Machhiwara 352852 08 2 2016 05
Mohali 152845 05 05 2016 15
;
RUN;
1
LIBNAME stat '/home/u4029796/SASClass';
2
DATA stat.Punjab;
3
INPUT Town $ 1-10 Zip 12-17 day 20-21 month 23-24
4
year 26-29 temperature 32-33;
5
DATALINES;
6
Ludhiana 1411010201201552
7
Amritsar 1420011306201528
8
Bathinda 152875058201643
9
Patiala 1875252507201520
10
Machhiwara 352852082201605
11
Mohali 1528450505201615
12
;
13
RUN;
2 Code Block
PROC PRINT
Explanation : This procedure displays the content of the 'stat.Punjab' dataset in the output window, with the title 'Punjab data set'.
Copied!
PROC PRINT DATA=stat.Punjab;
TITLE 'Punjab data set';
RUN;
1
2
PROC PRINT
3
DATA=stat.Punjab;
4
TITLE 'Punjab
5
data set';
6
RUN;
7
3 Code Block
DATA STEP Data
Explanation : This block recreates the 'stat' library (although already defined) and creates a new permanent dataset 'stat.Punjab1'. It reads the same raw data as before, but this time, the 'month' variable is explicitly defined as a character type variable ('$'), unlike in the first DATA step where it was numeric. Data is also provided inline via DATALINES.
Copied!
LIBNAME stat '/home/u4029796/SASClass';
DATA stat.Punjab1;
INPUT Town $ 1-10 Zip 12-17 day 20-21 month $ 23-24
year 26-29 temperature 32-33;
DATALINES;
Ludhiana 141101 02 01 2015 52
Amritsar 142001 13 06 2015 28
Bathinda 152875 05 8 2016 43
Patiala 187525 25 07 2015 20
Machhiwara 352852 08 2 2016 05
Mohali 152845 05 05 2016 15
;
RUN;
1
LIBNAME stat '/home/u4029796/SASClass';
2
DATA stat.Punjab1;
3
INPUT Town $ 1-10 Zip 12-17 day 20-21 month $ 23-24
4
year 26-29 temperature 32-33;
5
DATALINES;
6
Ludhiana 1411010201201552
7
Amritsar 1420011306201528
8
Bathinda 152875058201643
9
Patiala 1875252507201520
10
Machhiwara 352852082201605
11
Mohali 1528450505201615
12
;
13
RUN;
4 Code Block
PROC PRINT
Explanation : This procedure displays the content of the 'stat.Punjab1' dataset in the output window, with the title 'Punjab1 data set'. This allows for comparison of the data presentation with that of the 'stat.Punjab' dataset, particularly for the 'month' variable.
Copied!
PROC PRINT DATA=stat.Punjab1;
TITLE 'Punjab1 data set';
RUN;
1
2
PROC PRINT
3
DATA=stat.Punjab1;
4
TITLE 'Punjab1
5
data set';
6
RUN;
7
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.