@@ -25,7 +25,7 @@ As is customary, we import pandas and NumPy as follows:
25
25
This is often used in interactive work (e.g. `Jupyter notebook
26
26
<https://jupyter.org/> `_ or terminal) - the equivalent in SAS would be:
27
27
28
- .. code-block :: none
28
+ .. code-block :: sas
29
29
30
30
proc print data= df(obs = 5 );
31
31
run;
@@ -65,7 +65,7 @@ in the ``DATA`` step.
65
65
66
66
Every ``DataFrame `` and ``Series `` has an ``Index `` - which are labels on the
67
67
*rows * of the data. SAS does not have an exactly analogous concept. A data set's
68
- row are essentially unlabeled, other than an implicit integer index that can be
68
+ rows are essentially unlabeled, other than an implicit integer index that can be
69
69
accessed during the ``DATA `` step (``_N_ ``).
70
70
71
71
In pandas, if no index is specified, an integer index is also used by default
@@ -87,7 +87,7 @@ A SAS data set can be built from specified values by
87
87
placing the data after a ``datalines `` statement and
88
88
specifying the column names.
89
89
90
- .. code-block :: none
90
+ .. code-block :: sas
91
91
92
92
data df;
93
93
input x y;
@@ -121,7 +121,7 @@ will be used in many of the following examples.
121
121
122
122
SAS provides ``PROC IMPORT `` to read csv data into a data set.
123
123
124
- .. code-block :: none
124
+ .. code-block :: sas
125
125
126
126
proc import datafile=' tips.csv' dbms=csv out=tips replace;
127
127
getnames= yes;
@@ -156,7 +156,7 @@ Exporting Data
156
156
157
157
The inverse of ``PROC IMPORT `` in SAS is ``PROC EXPORT ``
158
158
159
- .. code-block :: none
159
+ .. code-block :: sas
160
160
161
161
proc export data= tips outfile= ' tips2.csv' dbms= csv;
162
162
run;
@@ -178,7 +178,7 @@ Operations on Columns
178
178
In the ``DATA `` step, arbitrary math expressions can
179
179
be used on new or existing columns.
180
180
181
- .. code-block :: none
181
+ .. code-block :: sas
182
182
183
183
data tips;
184
184
set tips;
@@ -207,7 +207,7 @@ Filtering
207
207
Filtering in SAS is done with an ``if `` or ``where `` statement, on one
208
208
or more columns.
209
209
210
- .. code-block :: none
210
+ .. code-block :: sas
211
211
212
212
data tips;
213
213
set tips;
@@ -233,7 +233,7 @@ If/Then Logic
233
233
234
234
In SAS, if/then logic can be used to create new columns.
235
235
236
- .. code-block :: none
236
+ .. code-block :: sas
237
237
238
238
data tips;
239
239
set tips;
@@ -262,7 +262,7 @@ Date Functionality
262
262
SAS provides a variety of functions to do operations on
263
263
date/datetime columns.
264
264
265
- .. code-block :: none
265
+ .. code-block :: sas
266
266
267
267
data tips;
268
268
set tips;
@@ -307,7 +307,7 @@ Selection of Columns
307
307
SAS provides keywords in the ``DATA `` step to select,
308
308
drop, and rename columns.
309
309
310
- .. code-block :: none
310
+ .. code-block :: sas
311
311
312
312
data tips;
313
313
set tips;
@@ -343,7 +343,7 @@ Sorting by Values
343
343
344
344
Sorting in SAS is accomplished via ``PROC SORT ``
345
345
346
- .. code-block :: none
346
+ .. code-block :: sas
347
347
348
348
proc sort data= tips;
349
349
by sex total_bill;
@@ -369,7 +369,7 @@ SAS determines the length of a character string with the
369
369
and `LENGTHC <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002283942.htm >`__
370
370
functions. ``LENGTHN `` excludes trailing blanks and ``LENGTHC `` includes trailing blanks.
371
371
372
- .. code-block :: none
372
+ .. code-block :: sas
373
373
374
374
data _null_;
375
375
set tips;
@@ -395,7 +395,7 @@ SAS determines the position of a character in a string with the
395
395
``FINDW `` takes the string defined by the first argument and searches for the first position of the substring
396
396
you supply as the second argument.
397
397
398
- .. code-block :: none
398
+ .. code-block :: sas
399
399
400
400
data _null_;
401
401
set tips;
@@ -419,7 +419,7 @@ Substring
419
419
SAS extracts a substring from a string based on its position with the
420
420
`SUBSTR <http://www2.sas.com/proceedings/sugi25/25/cc/25p088.pdf >`__ function.
421
421
422
- .. code-block :: none
422
+ .. code-block :: sas
423
423
424
424
data _null_;
425
425
set tips;
@@ -442,7 +442,7 @@ The SAS `SCAN <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/def
442
442
function returns the nth word from a string. The first argument is the string you want to parse and the
443
443
second argument specifies which word you want to extract.
444
444
445
- .. code-block :: none
445
+ .. code-block :: sas
446
446
447
447
data firstlast;
448
448
input String $ 60 .;
@@ -474,7 +474,7 @@ The SAS `UPCASE <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/d
474
474
`PROPCASE <http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a002598106.htm >`__
475
475
functions change the case of the argument.
476
476
477
- .. code-block :: none
477
+ .. code-block :: sas
478
478
479
479
data firstlast;
480
480
input String $ 60 .;
@@ -516,7 +516,7 @@ types of joins are accomplished using the ``in=`` dummy
516
516
variables to track whether a match was found in one or both
517
517
input frames.
518
518
519
- .. code-block :: none
519
+ .. code-block :: sas
520
520
521
521
proc sort data= df1;
522
522
by key;
@@ -572,7 +572,7 @@ operations, and is ignored by default for aggregations.
572
572
One difference is that missing data cannot be compared to its sentinel value.
573
573
For example, in SAS you could do this to filter missing values.
574
574
575
- .. code-block :: none
575
+ .. code-block :: sas
576
576
577
577
data outer_join_nulls;
578
578
set outer_join;
@@ -615,7 +615,7 @@ SAS's PROC SUMMARY can be used to group by one or
615
615
more key variables and compute aggregations on
616
616
numeric columns.
617
617
618
- .. code-block :: none
618
+ .. code-block :: sas
619
619
620
620
proc summary data= tips nway;
621
621
class sex smoker;
@@ -640,7 +640,7 @@ In SAS, if the group aggregations need to be used with
640
640
the original frame, it must be merged back together. For
641
641
example, to subtract the mean for each observation by smoker group.
642
642
643
- .. code-block :: none
643
+ .. code-block :: sas
644
644
645
645
proc summary data= tips missing nway;
646
646
class smoker;
@@ -679,7 +679,7 @@ replicate most other by group processing from SAS. For example,
679
679
this ``DATA `` step reads the data by sex/smoker group and filters to
680
680
the first entry for each.
681
681
682
- .. code-block :: none
682
+ .. code-block :: sas
683
683
684
684
proc sort data= tips;
685
685
by sex smoker;
@@ -719,7 +719,7 @@ Data Interop
719
719
pandas provides a :func: `read_sas ` method that can read SAS data saved in
720
720
the XPORT or SAS7BDAT binary format.
721
721
722
- .. code-block :: none
722
+ .. code-block :: sas
723
723
724
724
libname xportout xport ' transport-file.xpt' ;
725
725
data xportout.tips;
0 commit comments