<?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: Tidy dataset with missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579291#M164424</link>
    <description>&lt;P&gt;Merge the dataset back on itself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
merge
  origin (keep=varname where=(varname &amp;gt; ''))
  origin (keep=varlabel where=(varlabel &amp;gt; ''))
  origin (keep=vartype where=(vartype &amp;gt; ''))
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use call execute to create a data step that writes the empty dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set test end=eof;
if _n_ = 1 then call execute('data want;');
call execute(catx(' ','length',varname,vartype,';'));
call execute(cat('label ',varname,'="',varlabel,'";'));
if eof then call execute('stop;run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stop;&lt;/FONT&gt; will prevent any observation to be written.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2019 07:52:07 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-08-06T07:52:07Z</dc:date>
    <item>
      <title>Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579288#M164421</link>
      <description>&lt;P&gt;Hello, all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is the origin dataset:&lt;/P&gt;&lt;PRE&gt;data origin;
    infile datalines dlm=","; 
    input VARNAME : $10.
          VARLABEL: $20.
          VARTYPE : $3.;
datalines;
    _name1, ,
    _name2, ,
    _name3, ,
    ,label date,
    ,label version,
    ,label phase,
    , ,$10
    , ,$15
    , ,8
    ;
run;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;What I want:&lt;/STRONG&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;1. A tidied dataset like below (without missing values above):&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    infile datalines dlm=","; 
    input VARNAME : $10.
          VARLABEL: $20.
          VARTYPE : $3.;
datalines;
    _name1,label date,$10
    _name2,label version,$15
    _name3,label phase,8
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;2. Use the "want" dataset's variable characteristics to generate an empty dataset.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how to solve this two by programming with SAS, could someone give me a hand?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 07:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579288#M164421</guid>
      <dc:creator>Dominus</dc:creator>
      <dc:date>2019-08-06T07:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579290#M164423</link>
      <description>&lt;P&gt;Hi, Dominus.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I really got your ideia, I think you could use something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Generate N datasets, which one with the column not null you need&lt;/P&gt;&lt;P&gt;Note: the first dataset has the first non null value and so on...*/&lt;/P&gt;&lt;P&gt;data set1 (keep=varname) set2 (keep=varlabel) set3 (keep=vartype);&lt;BR /&gt;set origin;&lt;BR /&gt;if varname ^= '' then output set1;&lt;BR /&gt;if varlabel ^= '' then output set2;&lt;BR /&gt;if vartype ^= '' then output set3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*You need to keep the data in the right order in each dataset and then join them*/&lt;/P&gt;&lt;P&gt;data newData;&lt;BR /&gt;set set1; set set2; set set3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 07:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579290#M164423</guid>
      <dc:creator>MarcoGuimaraes</dc:creator>
      <dc:date>2019-08-06T07:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579291#M164424</link>
      <description>&lt;P&gt;Merge the dataset back on itself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
merge
  origin (keep=varname where=(varname &amp;gt; ''))
  origin (keep=varlabel where=(varlabel &amp;gt; ''))
  origin (keep=vartype where=(vartype &amp;gt; ''))
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use call execute to create a data step that writes the empty dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set test end=eof;
if _n_ = 1 then call execute('data want;');
call execute(catx(' ','length',varname,vartype,';'));
call execute(cat('label ',varname,'="',varlabel,'";'));
if eof then call execute('stop;run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stop;&lt;/FONT&gt; will prevent any observation to be written.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 07:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579291#M164424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T07:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579292#M164425</link>
      <description>&lt;P&gt;Thanks MarcoGuimaraes. I'm new to SAS and iI' still learning. Your thinking is very inspiring. Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 08:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579292#M164425</guid>
      <dc:creator>Dominus</dc:creator>
      <dc:date>2019-08-06T08:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579293#M164426</link>
      <description>&lt;P&gt;Thanks KurtBremser. Your answer is exactly what I want and your code is&amp;nbsp;simple look, but efficient and artistic. Thanks for your kindly help.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 08:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579293#M164426</guid>
      <dc:creator>Dominus</dc:creator>
      <dc:date>2019-08-06T08:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Tidy dataset with missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579295#M164427</link>
      <description>Importante note about "newData": the resource I've used to join the data is called one-to-one reading. It merges the datasets according to line position and the number of lines is always according to the smallest (with less lines) datasets.</description>
      <pubDate>Tue, 06 Aug 2019 08:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Tidy-dataset-with-missing-values/m-p/579295#M164427</guid>
      <dc:creator>MarcoGuimaraes</dc:creator>
      <dc:date>2019-08-06T08:26:42Z</dc:date>
    </item>
  </channel>
</rss>

