<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python-like Dictionaries in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465212#M118651</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149303"&gt;@mark4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&amp;nbsp; Can you explain a little more about what you mean and how it works?&amp;nbsp; I only know SAS Formats as a rather frustrating thing I have to deal with using date/time or converting between character and numeric, and I've never heard of &lt;SPAN&gt;CNTLIN&lt;/SPAN&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converting between may mean that you have a confusion between date, time and datetime&amp;nbsp;FORMATS, which are used to display SAS numeric values in human readable form and INFORMATS which are used to translate human readable dates, times and datetimes into computer useable numeric forms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc format allows you to create custom display formats or informats to read values into a variable.&lt;/P&gt;
&lt;P&gt;CNTLIN is an option for Proc Format that will use specific variable names and values to create a format. CNTLOUT is an option to create a data set from Proc format code that can be used as a CNTLIN dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does have dictionary tables but they are different than you may be familiar with. The SAS dictionary tables keep track of SAS items such as library characteristics (path associated data engine and such), table characteristics (name, number of variables, number of records, library membership, variable names and characteristics and which data sets they belong to, defined macros, titles, footnotes and other system items.&lt;/P&gt;</description>
    <pubDate>Fri, 25 May 2018 20:07:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-05-25T20:07:42Z</dc:date>
    <item>
      <title>Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465166#M118620</link>
      <description>&lt;P&gt;Does SAS have something similar to Python's dictionary?&amp;nbsp; For those unfamiliar, an easy way to think about it is a data set with two columns - name and value.&amp;nbsp; For example, the 'name' column could be a person's name, and the 'value' column could be their address.&amp;nbsp; One great feature about this is the ability to quickly 'look-up' the value for a given name.&amp;nbsp; If the dictionary was called dict, then to get John Doe's address, you evaluate the expression dict['John Doe'].&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could get the same result with something like&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select address into :Johns_Address from dict where name = "John Doe";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so calling &amp;amp;Johns_Address will return John Doe's address.&amp;nbsp; This is obviously clunky and less than ideal.&amp;nbsp; Are there shortcuts?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 17:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465166#M118620</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-25T17:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465172#M118624</link>
      <description>SAS Formats function like that and you can build them off a data set using CNTLIN. Then you use it, using a PUT or INPUT statement depending on the conversion direction.</description>
      <pubDate>Fri, 25 May 2018 17:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465172#M118624</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-25T17:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465174#M118625</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; Can you explain a little more about what you mean and how it works?&amp;nbsp; I only know SAS Formats as a rather frustrating thing I have to deal with using date/time or converting between character and numeric, and I've never heard of &lt;SPAN&gt;CNTLIN&lt;/SPAN&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 17:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465174#M118625</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-25T17:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465180#M118628</link>
      <description>&lt;P&gt;proc format does not only work from code, it can also create a format from a dataset (it's the cntlin= option in the proc format statement).&lt;/P&gt;
&lt;P&gt;To see how such a dataset should look like, create one with the cntlout= option.&lt;/P&gt;
&lt;P&gt;For a typical "lookup" format, you need just 4 variables:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;start, the "from" value&lt;/LI&gt;
&lt;LI&gt;label, the "to" value&lt;/LI&gt;
&lt;LI&gt;type, either 'C' or 'N'&lt;/LI&gt;
&lt;LI&gt;fmtname, the name of the format&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 17:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465180#M118628</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-25T17:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465181#M118629</link>
      <description>&lt;P&gt;Here’s a good paper with examples and code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/sugi30/001-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/001-30.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And some of the technical concepts:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings12/048-2012.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings12/048-2012.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your current references are built in SAS formats, but you can also create your own custom formats, User Defined Formats (UDF).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It’s basically a lookup table and faster than joins.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 17:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465181#M118629</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-25T17:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465212#M118651</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149303"&gt;@mark4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks.&amp;nbsp; Can you explain a little more about what you mean and how it works?&amp;nbsp; I only know SAS Formats as a rather frustrating thing I have to deal with using date/time or converting between character and numeric, and I've never heard of &lt;SPAN&gt;CNTLIN&lt;/SPAN&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converting between may mean that you have a confusion between date, time and datetime&amp;nbsp;FORMATS, which are used to display SAS numeric values in human readable form and INFORMATS which are used to translate human readable dates, times and datetimes into computer useable numeric forms.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc format allows you to create custom display formats or informats to read values into a variable.&lt;/P&gt;
&lt;P&gt;CNTLIN is an option for Proc Format that will use specific variable names and values to create a format. CNTLOUT is an option to create a data set from Proc format code that can be used as a CNTLIN dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does have dictionary tables but they are different than you may be familiar with. The SAS dictionary tables keep track of SAS items such as library characteristics (path associated data engine and such), table characteristics (name, number of variables, number of records, library membership, variable names and characteristics and which data sets they belong to, defined macros, titles, footnotes and other system items.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 20:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465212#M118651</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-25T20:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465260#M118665</link>
      <description>&lt;P&gt;Hash Table/Map .&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 10:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465260#M118665</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-26T10:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465667#M118788</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; I will certainly start using hashes.&amp;nbsp; The syntax and implementation is much cleaner, shorter, and easier to remember than using PROC FORMAT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quickly browsing the available resources implies you can only use hashes in a data set, and once you're out of the data step, they are no longer available, though.&amp;nbsp; Are there any work-around's to this?&amp;nbsp; For just one example, I would love to create something like this for all data sets:&amp;nbsp; Each data set corresponds to a key, and the value from that key is an array consisting of various attributes for the data set like number of rows, number of columns, column names, etc.&amp;nbsp; Having this with the ability to print a key's value to the log would make testing/debugging/exploring new data sets much more efficient.&amp;nbsp; I wouldn't have to get information on data sets of interest by hunting around library views to click on the data set, and I wouldn't have to sift through&amp;nbsp;far too much information printed to the Results tab when you use PROC CONTENTS.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 12:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465667#M118788</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-29T12:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465670#M118789</link>
      <description>&lt;P&gt;I'll have to look at the ctlin/ctlout options and see what they do.&amp;nbsp; (I don't even know what they're abbreviating.)&amp;nbsp; But a lot of my confusion comes from importing external data where dates are not formatted consistently.&amp;nbsp; At times they are text, sometimes they are displayed YYYYMMDD, other times YYYYJJJ where JJJ is the Julian date.&amp;nbsp; I usually just turn everything into numeric values and work from there.&amp;nbsp; Even this is not without problems since I cannot remember the difference in input vs put for converting between formats and the other 'format' syntax requirements (do I need a $ or a ., do I need some sort of length?).&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 12:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465670#M118789</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-29T12:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465672#M118790</link>
      <description>&lt;P&gt;Yeah. That is the benefit of FORMAT , which most people suggested.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 12:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465672#M118790</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-05-29T12:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465678#M118791</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; That's too bad you can't access hashes outside data steps.&amp;nbsp; It's such an inelegant solution.&amp;nbsp; Yet another reason having to segment SAS programs into all sorts of proc's, data sets, macros is so cumbersome...&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 12:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465678#M118791</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-29T12:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465757#M118800</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149303"&gt;@mark4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'll have to look at the ctlin/ctlout options and see what they do.&amp;nbsp; (I don't even know what they're abbreviating.)&amp;nbsp; But a lot of my confusion comes from importing external data where dates are not formatted consistently.&amp;nbsp; At times they are text, sometimes they are displayed YYYYMMDD, other times YYYYJJJ where JJJ is the Julian date.&amp;nbsp; I usually just turn everything into numeric values and work from there.&amp;nbsp; Even this is not without problems since I cannot remember the difference in input vs put for converting between formats and the other 'format' syntax requirements (do I need a $ or a ., do I need some sort of length?).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without seeing concrete examples I would guess that you are relying on Proc Import too much. Since Proc Import has to guess on variable characteristics based on a default very small number of records in a file imported this in not an uncommon issue, especially if you deal with marginally organized data such as from spreadsheets.&lt;/P&gt;
&lt;P&gt;SAS will usually default to assigning a display format to match the format the data was read from. In which case all that would be needed is to assign you preferred date format after the data is read (Proc datasets would modify the data set and variable properties like Format or label in place).&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 16:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465757#M118800</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-29T16:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465764#M118801</link>
      <description>&lt;P&gt;You're mixing up two concepts here, one is how SAS stores variables and formats them, and the second is how to import data correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Someone's already mentioned the import issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding variables and formats, Formats is actually one of the most powerful features of SAS in the long run. The presentation layer is separated from the data layer (which makes it a bit more abstract for the day to day users) but makes it much easier to manage data. I've started becoming more and more reliant on them after a decade of using SAS because they're versatile and quick.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For dates, they are numbers, you can subtract, add, increment them as necessary. The formats simply change how they're displayed. Its especially nice when I get data sets from American sources that store data in a mmddyyyy format I can change that right away to what the rest of the world uses.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using dates and times in SAS:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issues you're encountering are issues I face in all languages (Python and R included) - most import automatic procedures have issues and dates are stored as numbers in most languages, even Excel. The formats is a SAS specific issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 17:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465764#M118801</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T17:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465776#M118810</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp;I think I have an understanding of how formats work, but I have never thought about it in depth so I may be wrong.&amp;nbsp; For a variable that's declared a date, SAS stores it as a numeric value representing the amount of time between your date and some arbitrary point in time.&amp;nbsp; Then declaring the format simply dictates how the variable is displayed, but it does not change the value stored in the data set, right?.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree that dates are annoying no matter what you're using, and my annoyance isn't mixing up formatting and importing so much as just trying to manage inconsistent fields.&amp;nbsp; The trouble for me comes from having to remember the syntax for the various date functions (take Julian date to YYYYMMDD, vs take YYMMDD to YYYYMMDD, for example) in SAS and thinking about how that interacts with formats.&amp;nbsp; I receive sas files that contain fields that represent dates, but some are&amp;nbsp;stored as dates, dates, some as character, others as numeric, and some of these will later have to be exported to excel using the same display format.&amp;nbsp; That's why I find it easiest to just convert it all a fixed 'format' but as a character, and if I need to do some arithmetic, treat it as numeric for the moment.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 18:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465776#M118810</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-29T18:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465780#M118814</link>
      <description>&lt;P&gt;As I mention below, I receive a lot of data from SAS files created by others, and the issue is the inconsistency in how those dates are formatted.&amp;nbsp; I'll have to start using&amp;nbsp;PROC DATASETS for these before reading them in, it appears.&amp;nbsp; But for those cases where I do have to import from csv or excel, I don't understand how PROC DATASETS helps, though.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there not just a way to declare the variable types in a PROC IMPORT section, or the first time I go to use the data?&amp;nbsp; I find the large number of procedures you have to know to use SAS efficiently to be a hindrance.&amp;nbsp; I don't like cases where you have to break what should be a single step into multiple SAS steps (e.g., importing data according to user defined criteria like column names or variable types) - each step has it's own syntax and structure, and it makes it hard to keep track of how each works.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 18:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465780#M118814</guid>
      <dc:creator>mark4</dc:creator>
      <dc:date>2018-05-29T18:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465814#M118822</link>
      <description>That’s a data integration problem in your process, not a SAS issue per se. You’d have the same issues in any other system, including Python AFAIK.</description>
      <pubDate>Tue, 29 May 2018 20:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465814#M118822</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T20:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465835#M118823</link>
      <description>&lt;P&gt;I think you need to stop comparing SAS programs with the way other languages have implemented stuff - every language has its idiosyncracies. There are good reasons why SAS is structured the way it is and as your knowledge grows you will see many areas where SAS goes way beyond what you can do in other languages. To give you an example, using SAS formats as lookups is incredibly powerful. I've built DATA steps that do in excess of 100 SAS format lookups - try doing that in SQL table joins or hash lookups.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 21:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465835#M118823</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2018-05-29T21:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python-like Dictionaries in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465841#M118825</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149303"&gt;@mark4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Does SAS have something similar to Python's dictionary?&amp;nbsp; For those unfamiliar, an easy way to think about it is a data set with two columns - name and value.&amp;nbsp; For example, the 'name' column could be a person's name, and the 'value' column could be their address.&amp;nbsp; One great feature about this is the ability to quickly 'look-up' the value for a given name.&amp;nbsp; If the dictionary was called dict, then to get John Doe's address, you evaluate the expression dict['John Doe'].&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Yes.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;They are called formats.&amp;nbsp; Let's take your example of translating a name to an address. For that you would create a character format (since name is character value).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value $address
    'John Doe'='101 Main Street'
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then use the format to display the addresses.&amp;nbsp; For example to get frequency counts by address you could just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=users ;
  tables name ;
  format name $address.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to create a new variable that has the formatted value then use the PUT function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new ;
  set old;
  address=put(name,$address.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you already have the data for your format in a dataset then you can either use the data to generate the VALUE statement of PROC FORMAT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set name_address_list end=eof;
  file code ;
  if _n_=1 then put 'value $address';
  put name :$quote. '=' address :$quote. ;
  if eof then put ';';
run;
proc format;
%include code;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or convert the data into the data format that PROC FORMAT can use for generating formats.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fmtin ;
  set name_address_list (keep=name address) ;
  fmtname='$address';
  rename name=start address=label;
run;
proc format cntlin=fmtin; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 May 2018 21:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Python-like-Dictionaries-in-SAS/m-p/465841#M118825</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-29T21:38:37Z</dc:date>
    </item>
  </channel>
</rss>

