<?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: Create Datasets Based on Contents in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805113#M317103</link>
    <description>&lt;P&gt;Thank You very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 17:08:27 GMT</pubDate>
    <dc:creator>david27</dc:creator>
    <dc:date>2022-03-30T17:08:27Z</dc:date>
    <item>
      <title>Create Datasets Based on Contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805076#M317086</link>
      <description>&lt;P&gt;So I have this information:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Name of the variable&lt;/LI&gt;&lt;LI&gt;Type( Character / Numeric)&lt;/LI&gt;&lt;LI&gt;Length&lt;/LI&gt;&lt;LI&gt;Format&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Based on this information, I am required to produce a SAS Dataset with an additional &lt;STRONG&gt;date&lt;/STRONG&gt; variable- &lt;STRONG&gt;YearMonth (YYYYMM)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;We can populate the values inside the variable randomly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list of variables can be 2, 10 or 50.(var1 , var2, var3.....)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HAVE:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*HAVE*/
data have;
infile datalines missover ;
input varname :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t;TD&gt;G&lt;/TD&gt;&lt;TD&gt;H&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 14:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805076#M317086</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2022-03-30T14:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create Datasets Based on Contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805087#M317095</link>
      <description>&lt;P&gt;Please explain the logic that results in 202002 in the first row, 202003 in the second row, and so on. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805087#M317095</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-30T15:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Datasets Based on Contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805093#M317098</link>
      <description>&lt;P&gt;If you want to define variables from metadata then just use some type of code generation.&lt;/P&gt;
&lt;P&gt;For example you could generate a series of ATTRIB statements.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set have ;
  file code ;
  length name $51 ;
  name=nliteral(varname);
  put 'attrib ' name 'length=' @;
  if type=2 then put '$' @;
  put length @;
  if not missing(format) then put format= @;
  put ';';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then use those statements inside a data step to define the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  do yearmonth = '202002','202003','202004';
%include code / source2;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805093#M317098</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-30T15:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create Datasets Based on Contents</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805113#M317103</link>
      <description>&lt;P&gt;Thank You very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 17:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Datasets-Based-on-Contents/m-p/805113#M317103</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2022-03-30T17:08:27Z</dc:date>
    </item>
  </channel>
</rss>

