{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 03 -- Data Types and Formatting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Topics Covered:\n", "\n", "Numerics \n", "\n", "Boolean \n", "\n", "Strings \n", " \n", "Numerical Precision \n", " \n", "String Slicing \n", " \n", "String Formatting \n", "\n", "Resources \n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Generally, SAS programmers have not had to concern themselves with data types since the model for SAS is simple. Data types are either numeric (8.) or character (\$). SAS informats (both SAS-supplied and user-defined) provide the mappings for reading data types. Similarly, SAS formats provide the mappings needed to write various data types. Internally, SAS uses floating point representation, with all of the details handled under the covers.\n", "\n", "Python has three distinct numeric types. They are:\n", "\n", " Integers\n", " Floating point numbers\n", " Complex numbers\n", " \n", " \n", "Python Numeric types and their supported operations are described \n", "here. Neither SAS nor Python have requirements to declare data types. They are inferred by usage context. In addition, Python has a Boolean type which is a sub-type of integer. Complex numbers are not discussed here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Numerics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Below, x is an integer. y is a float\n", "\n", "Mathematical operations involving integers and floats produces a float. The type() method returns an object's type. Use the type() method to determine which object type is returned." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x is: \n", "y is: \n", "z is: 1.5 with type: \n" ] } ], "source": [ "x = 1\n", "y = 1.5\n", "z = x*y\n", "\n", "print('x is:', type(x))\n", "print('y is:', type(y))\n", "print('z is:', z, 'with type:', type(z))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the program below, the SAS variables x, y, and z are numeric. This example creates a temporary data set called “types”, which is searched within the dictionary tables (sashelp.vcolumn) to find the ‘type’ associated with these variables." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_x_is_int_y_is_float.sas */\n", " /******************************************************/\n", " 4 data types;\n", " 5 x = 1;\n", " 6 y = 1.5;\n", " 7 z = x*y;\n", " 8 \n", " 9 Put \"x is: \" x /\n", " 10 \"y is: \" y/\n", " 11 \"z is: \" z;\n", " 12 \n", " 13 title \"SAS Reported 'type' for numeric variables\";\n", "\n", " x is: 1\n", " y is: 1.5\n", " z is: 1.5\n", " \n", " 14 proc print data=sashelp.vcolumn(where=(libname='WORK' and\n", " 15 memname='TYPES'));\n", " 16 id name;\n", " 17 var type;\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/jpeg": "/9j/4AAQSkZJRgABAQEAYABgAAD/4RDcRXhpZgAATU0AKgAAAAgABAE7AAIAAAAGAAAISodpAAQA\nAAABAAAIUJydAAEAAAAMAAAQyOocAAcAAAgMAAAAPgAAAAAc6gAAAAgAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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nMjIj48cmRmOmxpPnJhbmR5PC9yZGY6bGk+PC9yZGY6U2VxPg0KCQkJPC9kYzpjcmVhdG9yPjwv\ncmRmOkRlc2NyaXB0aW9uPjwvcmRmOlJERj48L3g6eG1wbWV0YT4NCiAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\nICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgPD94cGFja2V0IGVuZD0ndyc/Pv/b\nAEMABwUFBgUEBwYFBggHBwgKEQsKCQkKFQ8QDBEYFRoZGBUYFxseJyEbHSUdFxgiLiIlKCkrLCsa\nIC8zLyoyJyorKv/bAEMBBwgICgkKFAsLFCocGBwqKioqKioqKioqKioqKioqKioqKioqKioqKioq\nKioqKioqKioqKioqKioqKioqKioqKv/AABEIAJQB/AMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAA\nAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEU\nMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2Rl\nZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK\n0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUG\nBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS\n8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4\neXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri\n4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APpGvKfEv7Rfgbw3rM2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9cjIXrjHvVTV9D8Q+INavtS/sKaxjnGlLHDcXEJk/cXjSSk7HZRhTkYY\n5GO/A9GxqP8Az7Wv/gS3/wARRjUf+fa1/wDAlv8A4ioTSafb/Nv9RqNk13t+Fv8AI4/WfDupXdp4\nyW3tQ76mYfsvzqPNCxIp6njBB64rrr//AI94/wDr4h/9GrTsaj/z7Wv/AIEt/wDEUyWC/uPLSSG2\nRRLG7Ms7McK4bpsHp60tLWHbW5pUUUVJQUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAB\nRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFF\nFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUU\nUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//Z\n", "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import Image\n", "Image(filename='Anaconda3\\\\output\\\\sas data types.JPG')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Boolean \n", "\n", "Because of its utility in data cleansing and transformations we will cover this in detail. The Python boolean comparison operators are found\n", "\n", "here.\n", "\n", "The two Boolean values are True and False with the capitalization as shown. In numeric contexts (for example, when used as an argument to an arithmetic operator), they behave like the integers with values 0 and 1, respectively.\n", "\n", "SAS does not have a boolean data type, so Data Step code is often constructed as a series of cascading IF-THEN/DO code blocks for testing True/False. \n", "\n", "SAS does have implied boolean test operators. An example is the END= option on the SET statement. It is initialized to 0 and set to 1 when the last observation in a data set is read. PROC SQL uses implied " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "True\n" ] } ], "source": [ "print(type(True))\n", "print(bool(True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Empty sets return False, Non-empty sets return True" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "False\n", "True\n" ] } ], "source": [ "print(bool('')) \n", "print(bool('Arbitrary String')) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Boolean values for 0 and 1" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "False\n", "True\n" ] } ], "source": [ "print(bool(0))\n", "print (bool(1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Inequality comparison" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = 2\n", "y = 3\n", "x != y" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_inequality_comparison.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 /* inequality comparison */\n", " 6 x = 2;\n", " 7 y = 3;\n", " 8 \n", " 9 if x ^= y then\n", " 10 put 'True';\n", " 11 else put 'False';\n", " \n", " True\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "String equality comparison. Note the case for the first letter in each string." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s1 = 'String'\n", "s2 = 'string'\n", "s1 == s2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "SAS example for string equality test." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_string_equality_comparison.sas */\n", " /******************************************************/\n", " 17 data _null_;\n", " 18 \n", " 19 /* string equality comparison */\n", " 20 s1 = 'String';\n", " 21 s2 = 'string';\n", " 22 \n", " 23 if s1 = s2 then\n", " 24 put 'True';\n", " 25 else put 'False';\n", "\n", " False\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "in comparison with the boolean 'and' operator" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s3 = 'Longer String'\n", "'r' and \"\" in s3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "SAS example with boolean 'and' operator. The SAS function FINDC is documented here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_in_comparison_with_and_operator.sas */\n", " /******************************************************/\n", " 31 data _null_;\n", " 32 \n", " 33 /* equivalent for in comparison with 'and' operator */\n", " 34 s3 = 'Longer String';\n", " 35 \n", " 36 if findc(s3,'r') ^= 0 and findc(s3,' ') ^= 0 then\n", " 37 put 'True';\n", " 38 else put 'False';\n", " 39 run;\n", "\n", "True\n", "\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "in comparison with boolean 'or' operator" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s4 = 'Skinny'\n", "s5 = 'hungry'\n", "'y' in s4 or s5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS program below is another illustration of implied boolean logic. The FINDC function searches a string for the first occurrence of the specified characters, and returns the position of the first character found. It returns 0 if the characters are not found--effectively returning 'false'." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_findc_function.sas */\n", " /******************************************************/\n", " 45 data _null_;\n", " 46 \n", " 47 /* Equivalent in comparison with 'or operator */\n", " 48 s4 = 'Skinny';\n", " 49 s5 = 'hungry';\n", " 50 \n", " 51 if findc(s4,'y') ^= 0 or findc(s5,'y') ^= 0 then\n", " 52 put 'True';\n", " 53 else put 'False';\n", "\n", " True\n", " \n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "is operator" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x1 = 4\n", "type(x1) is int and x1 <= 5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is a mathematical truth that .1 multiplied by 10 produces 1 (for base10 of course). Read the numerical precision section below to understand why the boolean equality test below returns False." ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = [.1] * 10\n", "x == 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Numerical Precision \n", "\n", "Consider the issue of numerical precision and the use of the round() method below. This example does a boolean comparison between the product of (.1 * 10) and the integer value of 1. Due to how floats are represented internally the comparison is False. Using the round() method for the product makes the comparison true (assuming that is what you want to have happen)." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Boolean expression one == total evaluates to: False\n", "Boolean expression one == round(total) evaluates to: True\n", "Total is: 0.9999999999999999 and type is: \n" ] } ], "source": [ "one = 1\n", "total = 0\n", "\n", "list = [.1] * 10 # List a data structure containing an ordered set of objects\n", "\n", "for i in list:\n", " total += i\n", "print('Boolean expression one == total evaluates to:', one == total) \n", "print('Boolean expression one == round(total) evaluates to:', one == round(total))\n", "print('Total is:', total, 'and type is:', type(total))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For a detailed explanation as to why, details are found \n", "here. The explanation applies to both Python and SAS.\n", "\n", "SAS produces the same results as the Python example above. Without the ROUND function the comparison of the product (.1 * 10) and the integer value 1 evaluates 'False'. Applying the ROUND function to the accumulator variable 'total' evaluates the comparison 'True'. \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "\n", " /******************************************************/\n", " /* c03_numerical_precision.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 one = 1;\n", " 6 total = 0;\n", " 7 inc = .1;\n", " 8 \n", " 9 do i = 1 to 10;\n", " 10 total + inc;\n", " 11 put inc ', ' @@;\n", " 12 end;\n", " 13 \n", " 14 put;\n", " 15 if total = one then put 'True';\n", " 16 else put 'Comparison of \"one = total\" evaluates to False';\n", " 17 \n", " 18 if round(total) = one then put 'Comparison of \"one = round(total)\" evaluates to Tru\n", " 18 ! e';\n", " 19 else put 'False';\n", " 20 \n", " 21 put 'Total is: ' total 8.3;\n", "\n", " 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , 0.1 , \n", " Comparison of \"one = total\" evaluates to False\n", " Comparison of \"one = round(total)\" evaluates to True\n", " Total is: 1.000\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Strings\n", "\n", "Strings can be enclosed in single quotes (') or double quotes (\"). In Python strings are a sequence of Unicode characters. Strings are immutable, so string methods() only return a new sequence. And because everything in Python is an object, we can use the form object.method() to apply a given method to these objects. These include built-in formatting." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "String literal assignment and concatenation" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello World\n", "HelloWorld\n", "Type() for s5 is: \n" ] } ], "source": [ "s5 = 'Hello'\n", "s6 = \"World\"\n", "\n", "print(s5, s6)\n", "print(s5+s6) \n", "print('Type() for s5 is:', type(s5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "SAS analog example for string literal assignment and concatentation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_string_literal_assignment_concatentation.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 s5 = 'Hello';\n", " 6 s6 = 'World';\n", " 7 \n", " 8 put s5 s6;\n", " 9 concat = cat(s5, s6);\n", " 10 \n", " 11 put concat;\n", "\n", " Hello World\n", " HelloWorld\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The len() method finds the length of the concatenated string literals." ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(s5) + len(s6)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS analog to finding the length of the concatenate string literals." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_find_len_concatenated_string.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 s5 = 'Hello';\n", " 6 s6 = 'World';\n", " 7 \n", " 8 len = length(cat(s5, s6));\n", " 9 \n", " 10 put len;\n", "\n", " 10\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The upper() method applied to a string object" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello WORLD\n" ] } ], "source": [ "print(s5 + \" \" + s6.upper())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS analog example using the UPCASE function documented here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_upper_method_on_string.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 s5 = 'Hello';\n", " 6 s6 = 'World';\n", " 7 \n", " 8 upcase = cat(s5, ' ', upcase(s6));\n", " 9 \n", " 10 put upcase;\n", "\n", " Hello WORLD\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python's help is quite extensive." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "['__add__',\n", " '__class__',\n", " '__contains__',\n", " '__delattr__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__getitem__',\n", " '__getnewargs__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__iter__',\n", " '__le__',\n", " '__len__',\n", " '__lt__',\n", " '__mod__',\n", " '__mul__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__rmod__',\n", " '__rmul__',\n", " '__setattr__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " 'capitalize',\n", " 'casefold',\n", " 'center',\n", " 'count',\n", " 'encode',\n", " 'endswith',\n", " 'expandtabs',\n", " 'find',\n", " 'format',\n", " 'format_map',\n", " 'index',\n", " 'isalnum',\n", " 'isalpha',\n", " 'isdecimal',\n", " 'isdigit',\n", " 'isidentifier',\n", " 'islower',\n", " 'isnumeric',\n", " 'isprintable',\n", " 'isspace',\n", " 'istitle',\n", " 'isupper',\n", " 'join',\n", " 'ljust',\n", " 'lower',\n", " 'lstrip',\n", " 'maketrans',\n", " 'partition',\n", " 'replace',\n", " 'rfind',\n", " 'rindex',\n", " 'rjust',\n", " 'rpartition',\n", " 'rsplit',\n", " 'rstrip',\n", " 'split',\n", " 'splitlines',\n", " 'startswith',\n", " 'strip',\n", " 'swapcase',\n", " 'title',\n", " 'translate',\n", " 'upper',\n", " 'zfill']" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(str) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python also supports a multi-line string literal that preserves spacing. It is also used to display help topics." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Beautiful is better than ugly.\n", "Explicit is better than implicit.\n", "Simple is better than complex.\n", "Complex is better than complicated.\n", "Flat is better than nested.\n", "Sparse is better than dense.\n", "Readability counts, and so on.\n" ] } ], "source": [ "s7 = '''Beautiful is better than ugly.\n", "Explicit is better than implicit.\n", "Simple is better than complex.\n", "Complex is better than complicated.\n", "Flat is better than nested.\n", "Sparse is better than dense.\n", "Readability counts, and so on.'''\n", "\n", "print(s7)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The count method() " ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Occurances of the letter \"c\": 6\n" ] } ], "source": [ "print('Occurances of the letter \"c\":', s7.count('c'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A contrast between SAS and Python is how Python preserves the line terminations for the string literals or DocStrings. SAS removes the line termination characters such that a PUT statement renders a single line wrapped to the width of the SAS log." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_count_occurences_of_letter_c.sas */\n", " /******************************************************/\n", " 5 data _null_;\n", " 6 s7 =\n", " 7 'Beautiful is better than ugly.\n", " 8 Explicit is better than implicit.\n", " 9 Simple is better than complex.\n", " 10 Complex is better than complicated.\n", " 11 Flat is better than nested.\n", " 12 Sparse is better than dense.\n", " 13 Readability counts, and so on.';\n", " 14 \n", " 15 count = countc(s7,'c');\n", " 16 \n", " 17 put 'Occurances of the letter \"c\": ' count;\n", "\n", " Occurances of the letter \"c\": 6\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## String Slicing\n", "\n", "Python uses indexing methods on a number of different objects having similar behaviors depending on the object. With a sequence of characters (string) Python automatically creates an index with a start position of zero (0) and increments to an end position of the string's length -1. The index can be thought of as one-dimensional array.\n", "\n", "At times, you may find it easier to refer to characters toward the end of the string. Python provides an 'end-to-beginning' indexer with a start position of -1 for the last character in the string and decrements to the beginning position. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 Character \n", " H e l l o W o r l d Index \n", " 0 1 2 3 4 5 6 7 8 9 10 Index Value R to L \n", " -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "String slicing with index at 0" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'H'" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s = 'Hello World'\n", "s[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS analog example uses the SUBSTR (right of =) function documented here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_slicing_with_index_at_zero.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 s = 'Hello World';\n", " 6 \n", " 7 extract = substr(s, 1, 1);\n", " 8 \n", " 9 put extract;\n", "\n", " H\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "No start position provide implies the start position of 0" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Hello'" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s[:5]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start at position 3 and go to the last character. Notice how the this range is not inclusive." ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'lo Worl'" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s[3:-1]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start from the end of the string and read to the left." ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'H'" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s[-11]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The partition() method uses a separator, in our example, a whitespace and returns a 3 part tuple. 0 for the part before the separator, 1 for the separator itself, and 2 for part after the separator." ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Beautiful\n" ] } ], "source": [ "if s7.startswith('Bea'):\n", " print(s7.partition(' ')[0])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS analog example uses the SUBSTR and the SCAN function, documented here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_startswith_partition.sas */\n", " /******************************************************/\n", " 23 data _null_;\n", " 24 \n", " 25 s7='Beautiful is better than ugly.\n", " 26 Explicit is better than implicit.\n", " 27 Simple is better than complex.\n", " 28 Complex is better than complicated.\n", " 29 Flat is better than nested.\n", " 30 Sparse is better than dense.\n", " 31 Readability counts, and so on.';\n", " 32 \n", " 33 if substr(s7, 1, 3) = 'Bea' then\n", " 34 found= scan(s7, 1, ' ');\n", " 35 \n", " 36 put found;\n", "\n", " Beautiful\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Backslashes (\\\\) are used as string literal escape characters. The Python interpreter ignores the character follwing the backslash." ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python's capabilities\n" ] } ], "source": [ "q = 'Python\\'s capabilities'\n", "print(q)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## String Formatting\n", "\n", "A format string contains one or more format codes in fields (which are replaced) within string constants. These fields to be replaced are surrounded by curly braces {}. There are two types of arguments to the .format() method. They are positional and keyword arguments.\n", "\n", "If the positional parameters are used in the order in which they are written, the argument specifiers inside of the braces can be omitted. Thus, '{} {} {}' corresponds to '{0} {1} {2}'. But they are needed if you want to access them in different orders: e.g. '{2} {1} {0}'. \n", "\n", "The Python documentation is located here. \n", "\n", "Python's formatting interface has undergone significant changes between version 2 and version 3. In older versions the syntax is **format % values** where **format** is a string, and **%** conversion specifications in format are replaced with elements of values. Our examples will use the newer style syntax.\n", "\n", "Python has a rich set of formatting capabilities which we only touch upon here. Our goal is to get enough exposure to be able to get to the task of analyzing and understanding data. In subsequent chapters, we will see additional examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### *Strings*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python is a language that is undergoing continued development. Prior to Python 3.x, string formatting used percent symbol (%) as a means for designating string arguments. This older-style syntax is preserved for backward compatibility reasons. \n", "\n", "The old-style syntax is not used here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'First argument: Python, second argument: Formatting'" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"First argument: %s, second argument: %s\" % ('Python', 'Formatting')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Left-alignment, field width 30" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Example of: left aligned, width is 30 '" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Example of: {:<30}'.format(\"left aligned, width is 30\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Right-alignment, field width 40" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Example of: right aligned, width is 40'" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Example of: {:>40}'.format(\"right aligned, width is 40\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Centered and filled" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Example of: ******centered and fill characters******'" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Example of: {:*^40}'.format('centered and fill characters') " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### *Integers*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Newer-style syntax with arguments displayed in the order they appear in the list" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'First argument: 20, second argument: 16'" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"First argument: {}, second argument: {}\".format(20, 16)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Arguments displayed in an order different than the way they appear in the list" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Second Argument: 16, first argument 20'" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"Second Argument: {1}, first argument {0}\".format(20, 16)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Converting values to different bases. " ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'int: 99; hex: 63; oct: 143; bin: 1100011'" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ " \"int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}\".format(99)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS analog for converting values to different bases." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_convert_values_to_different_base.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 input int 8.;\n", " 6 put 'int: ' int 8. ' hex: ' int hex2. ' octal: ' int octal. ' binary: ' int binary8.;\n", " 7 put 'Original input: ' _infile_;\n", " 8 datalines;\n", "\n", " int: 99 hex: 63 octal: 143 binary: 01100011\n", " Original input: 99 \n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Formatting to handle ints" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Integer 99 displayed as 99'" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Integer 99 displayed as {:d}'.format(99)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Controlling field width for integers" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'Integer 99 displayed as 0099'" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Integer 99 displayed as {:04d}'.format(99)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_formatting_to_handle_ints.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 input int 8.;\n", " 6 \n", " 7 /* display_int is a character variable */\n", " 8 display_int = put(int,z4.);\n", " 9 put 'int: ' display_int;\n", " 10 \n", " 11 put 'Original input: ' _infile_;\n", " 12 datalines;\n", "\n", " int: 0099\n", " Original input: 99\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, only negative numbers are prefixed with a sign" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'+99'" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'{:=+3d}'.format((+99))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "SAS users are familiar with user-written formats. The example displayed below uses a PICTURE statement with PROC FORMAT in order to a numeric preceeded by a plus-sign." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_postive_numbers_are_signed.sas */\n", " /******************************************************/\n", " 4 /* Method without converting int to a character string */\n", " 5 proc format;\n", " 6 picture plussign\n", " 7 low - high = ' 00' (prefix='+');\n", " 8 \n", " 9 data _null_;\n", " 10 input int 8.;\n", " 11 \n", " 12 put 'int: ' int plussign.;\n", " 13 put 'Original input: ' _infile_;\n", "\n", " int: +99\n", " Original input: 99\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### *Floats*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Formatting to handle floats" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'precision: 3.1 or 3.1416'" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"precision: {0:.1f} or {0:.4f}\".format(3.14159265)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Analog SAS program used to control numeric formatting." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_control_numeric_formatting.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 pi = 3.14159265;\n", " 6 \n", " 7 put 'precision: ' pi 8.1 ' or ' pi 8.4;\n", "\n", " precision: 3.1 or 3.1416\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Percentage format" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'6.33 as Percentage of 150: 4.22%'" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"6.33 as Percentage of 150: {0:6.2%}\".format(6.33/150)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_percentage_format.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 pct = 6.33 / 150;\n", " 6 \n", " 7 put '6.33 as a percentage of 150: ' pct percent8.2;\n", "\n", " 6.33 as a percentage of 150: 4.22% \n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Datetime\n", "\n", "Python permits the manipulations of dates and times. In these examples the date, datetime, and time objects use the strftime(format) method to create strings illustrating datetime extracts and formatting. Chapter 08 -- Date, Time, and Timedelta Objects illustrates additional datetime arithmetic examples and durations calculations. The Python directives for datetime formatting are found here.\n", "\n", "Notice the dates and times between the Python and SAS examples do not match since they are being executed at different dates and times." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python datetime objects" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2016-12-02 13:57:34.310391\n", "\n" ] } ], "source": [ "from datetime import datetime, date, time\n", "now = datetime.now()\n", "print(now)\n", "print(type(now))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Extrating dates and times" ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Default output: 2016-12-02 13:57:34.376403\n", "Year: 2016\n", "Month: December\n", "Day: 02\n", "\n", "concat1: Friday, December 02, 2016 A.D.\n", "current datetime: Fri Dec 2 13:57:34 2016\n" ] } ], "source": [ "now = datetime.now()\n", "\n", "print('Default output:', now)\n", "print('Year:', now.strftime(\"%Y\"))\n", "print('Month:', now.strftime(\"%B\"))\n", "print('Day:', now.strftime(\"%d\"))\n", "print()\n", "print('concat1:', now.strftime(\"%A, %B %d, %Y A.D.\"))\n", "print('current datetime:', now.strftime(\"%c\"))" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_extract_date_time.sas */\n", " /******************************************************/\n", " 4 data _null_;\n", " 5 \n", " 6 * Get Year;\n", " 7 date = today();\n", " 8 year_pt = year(date);\n", " 9 \n", " 10 * Get Month;\n", " 11 month_nm = put(date, monname.);\n", " 12 month_pt2 = put(date, monname3.);\n", " 13 \n", " 14 * Get Day;\n", " 15 day_pt = put(day(date), z2.);\n", " 16 date2 = day(date);\n", " 17 dow1 = put(date, downame.);\n", " 18 dow2 = put(date, downame3.);\n", " 19 \n", " 20 * Get time;\n", " 21 now = time();\n", " 22 tm = put(now, time8.);\n", " 23 \n", " 24 * whitespace, comma, suffix;\n", " 25 ws = ' ';\n", " 26 comma = ',';\n", " 27 ad = 'A.D';\n", " 28 \n", " 29 put 'Default output: ' date ' for time ' now;\n", " 30 put 'Year: ' year_pt;\n", " 31 put 'Month: ' month_nm;\n", " 32 put 'Day: ' day_pt /;\n", " 33 \n", " 34 concat1 = cat(dow1, comma, month_nm, ws, day_pt, comma, ws, year_pt, ws, ad);\n", " 35 concat2 = cat(dow2, ws, month_pt2, ws, date2, ws, tm, ws, year_pt);\n", " 36 \n", " 37 put 'concat1: ' concat1;\n", " 38 put 'current datetime: ' concat2;\n", "\n", " Default output: 20736 for time 71660.228\n", " Year: 2016\n", " Month: October Day: 09\n", "\n", " concat1: Sunday, October 09, 2016 A.D\n", " current datetime: Sun Oct 9 19:54:20 2016\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a date string. " ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dt_str is: 2016-10-09 08:07\n", "dt_str is \n" ] } ], "source": [ "dt_str = '{:%Y-%m-%d %H:%M}'.format(datetime(2016, 10, 9, 8, 7))\n", "print('dt_str is:', dt_str)\n", "print('dt_str is', type(dt_str))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The SAS example below reads a date-string literal with the informat datetime15. and uses the PUT function to associate it with the datetime15. format. This does not create a SAS datetime value." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " /******************************************************/\n", " /* c03_convert_datetime_to_string.sas */\n", " /******************************************************/\n", "\n", " 4 data _null_;\n", " 5 input dt datetime15.;\n", " 6 \n", " 7 *this converts a SAS datetime value to a character variable;\n", " 8 dt_str = put(dt, datetime15.);\n", " 9 \n", " 10 put 'dt_str is: ' dt_str;\n", " 11 \n", " 12 list;\n", " 13 lines;\n", "\n", " dt_str is: 09OCT16:08:07\n", " RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+- \n", " \n", " 14 09Oct2016:08:07\n", " \n", "" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Resources\n", "\n", " 4. Built-in Types from Python 3.6 Documentation, The Python Standard Library.\n", "\n", "Pre-Processing Text Data from Duke University's \"Computational Statistics in Python\"\n", "\n", " Strings, Part 3 from Hands-on Python Tutorial by Andrew N. Harrington, Computer Science Department, Loyola University Chicago\n", "\n", " PyFormat Using % and .format() for great good! Curated by Ulrich Petri & Horst Gutmann\n", "\n", " SAS Variables in the SAS 9.2 Language Reference: Concepts, Second Edition\n", "\n", " Missing Values cited above." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Navigation\n", "\n", " Return to Chapter List " ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [Root]", "language": "python", "name": "Python [Root]" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }