<?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: SAS Meta Data Driven Programming SAS 9.3 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553448#M9385</link>
    <description>&lt;P&gt;If your requirement is for single variables then perhaps an INFORMAT is appropriate to read data in a custom manner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2019 22:00:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-23T22:00:44Z</dc:date>
    <item>
      <title>SAS Meta Data Driven Programming SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553240#M9339</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am pretty good at programming in SAS but I have been unable to determine a straight forward way to create new variables in a dataset using metadata. I am creating a process that creates datasets using a data dictionary but I would like to incorporate this dictionary for new variables as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to create a data dictionary for variables that I want created during data processing that would be based off the variables in the data dictionary? I don't want to include a bunch of if/then statements. As I think about this I believe it may be possible to put if/then statements into a metadata table and run them from a sas macro but I wonder if there is a cleaner way to accomplish that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me know if I need to be clearer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 13:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553240#M9339</guid>
      <dc:creator>lmcglone</dc:creator>
      <dc:date>2019-04-23T13:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Meta Data Driven Programming SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553272#M9345</link>
      <description>&lt;P&gt;Please provide a simple example of data set before and after your change using &lt;FONT face="courier new,courier"&gt;datalines&lt;/FONT&gt; code, that can be run by anyone as is, explaining what the logic /&amp;nbsp;rules are for creating the new variable(s).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 14:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553272#M9345</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-04-23T14:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Meta Data Driven Programming SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553378#M9365</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. Below is a brief program for what I am trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dict;&lt;BR /&gt;input var $ type $ length 2. varnum 2.;&lt;BR /&gt;datalines;&lt;BR /&gt;name char 10 1&lt;BR /&gt;dept char 10 2&lt;BR /&gt;age num 2 3&lt;BR /&gt;sex char 1 4&lt;BR /&gt;graduated char 1 5&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input var1 $ var2 $ var3 2. var4 $ var5 $;&lt;BR /&gt;datalines;&lt;BR /&gt;John Sales 30 M Y&lt;BR /&gt;Mary Acctng 40 F N&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;%macro format;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select var, type, length, varnum&lt;BR /&gt;into :mvar1- , :mtype1-, :mlength1-, :mvarnum1-&lt;BR /&gt;from dict;&lt;BR /&gt;%let count = &amp;amp;sqlobs;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;%do v = 1 %to &amp;amp;count;&lt;BR /&gt;rename var&amp;amp;v = &amp;amp;&amp;amp;&amp;amp;mvar&amp;amp;v;&lt;BR /&gt;%end; /* end generate variable type conversion */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set temp;&lt;BR /&gt;if graduate = "Y" then school = "college";&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I idea is that I have a data dictionary that includes metadata for the variables represented in a dataset. I use this data dictionary to manipulate the dataset (eg. rename variables, change data types, set variable lengths, etc.). In the example I added the if/then statement (if graduate = "Y" then school = "college") creating a new variable named "school". What I want to do is have this variable created from a data dictionary in the macro instead of me adding an if/then statement to create it. I have tried to add the if/then statement to the data dictionary and that works but I wonder if there is a cleaner way to do it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The endgame for this idea is to have a data dictionary that I can add variables to the will get added to the dataset whenever the macro runs instead of adding if/then statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 18:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553378#M9365</guid>
      <dc:creator>lmcglone</dc:creator>
      <dc:date>2019-04-23T18:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Meta Data Driven Programming SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553448#M9385</link>
      <description>&lt;P&gt;If your requirement is for single variables then perhaps an INFORMAT is appropriate to read data in a custom manner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 22:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/553448#M9385</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-23T22:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Meta Data Driven Programming SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/555114#M9601</link>
      <description>&lt;P&gt;I was unable to get the example code provided to complete successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need to conditionally assign each new variable you create then you could try creating a separate data set that holds your logic, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data logic;
   infile datalines truncover;
   input logic $char200.;
   datalines;
if graduate = "Y" then school = "college"
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then any number of logic lines could be used for any number of new variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 16:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Meta-Data-Driven-Programming-SAS-9-3/m-p/555114#M9601</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-04-30T16:20:09Z</dc:date>
    </item>
  </channel>
</rss>

