<?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: Initialize some variables of datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387268#M92840</link>
    <description>&lt;PRE&gt;data varexclu1; 
set varexclu; 
	if type eq "num" then varE = cat(compress(name)," =;");
	else varE = cat(compress(name),' =" " ;');
run; 
proc sql noprint; 
select varE into :vE separated by '  ' 
from varexclu1; 
quit; 

%put "&amp;amp;vE.";
data in; 
set out ;
		num 		  = 643;
		STAT	  = 6;
	        &amp;amp;vE.;
 run; &lt;/PRE&gt;</description>
    <pubDate>Fri, 11 Aug 2017 09:31:01 GMT</pubDate>
    <dc:creator>amager</dc:creator>
    <dc:date>2017-08-11T09:31:01Z</dc:date>
    <item>
      <title>Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387263#M92837</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to initialize some variables of my datasets;&lt;/P&gt;&lt;P&gt;what i do is to create a macro variable contains the variable to initialize;&lt;/P&gt;&lt;P&gt;macro variable is like this&amp;nbsp; var1=.; var 2=""; ...etc.&lt;/P&gt;&lt;P&gt;In a data step i want to include this macro variable&amp;nbsp; by&amp;nbsp; &amp;amp;mv.;&amp;nbsp; to initialize this variables after a set statement, but put this error :"ERROR 180-322: Statement is not valid or it is used out of proper order."&lt;/P&gt;&lt;P&gt;So if sameone know how to do it !&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>Fri, 11 Aug 2017 09:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387263#M92837</guid>
      <dc:creator>amager</dc:creator>
      <dc:date>2017-08-11T09:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387265#M92838</link>
      <description>&lt;P&gt;Post code and log. Use the proper sub-windows ({i} and "little running man") for this.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387265#M92838</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-11T09:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387267#M92839</link>
      <description>&lt;P&gt;I would say your hitting Learn SAS 01 Problem, lack of understanding what Macro is and how it relates to Base SAS. &amp;nbsp;Base SAS is the programming language, it uses data, does manipulations etc. &amp;nbsp;Macro is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; for this, it is purely a find replace/text generation utility. &amp;nbsp;Creation of variables should be done in Base SAS, within a datastep. &amp;nbsp;Not doing this will result in errors. &amp;nbsp;In&amp;nbsp;&lt;STRONG&gt;all&amp;nbsp;&lt;/STRONG&gt;cases, macro is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; needed, get code working, then if you see some repeating code, then it is the time to look at macro. &amp;nbsp;Without further information I cannot suggest. &amp;nbsp;Follow the guidance below Post button - post test data in the form of a datastep in a code window (its the {i} above post) and post what you want out.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387267#M92839</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-11T09:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387268#M92840</link>
      <description>&lt;PRE&gt;data varexclu1; 
set varexclu; 
	if type eq "num" then varE = cat(compress(name)," =;");
	else varE = cat(compress(name),' =" " ;');
run; 
proc sql noprint; 
select varE into :vE separated by '  ' 
from varexclu1; 
quit; 

%put "&amp;amp;vE.";
data in; 
set out ;
		num 		  = 643;
		STAT	  = 6;
	        &amp;amp;vE.;
 run; &lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387268#M92840</guid>
      <dc:creator>amager</dc:creator>
      <dc:date>2017-08-11T09:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387271#M92841</link>
      <description>any solution ?</description>
      <pubDate>Fri, 11 Aug 2017 09:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387271#M92841</guid>
      <dc:creator>amager</dc:creator>
      <dc:date>2017-08-11T09:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387272#M92842</link>
      <description>&lt;P&gt;If you use the call missing() subroutine in your created statements, you do not need to distinguish between character and numeric.&lt;/P&gt;
&lt;P&gt;Otherwise, use a dot to set numerics to missing. X=; won't work.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:44:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387272#M92842</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-11T09:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387274#M92843</link>
      <description>&lt;P&gt;Give a valid scenario of where this would be used. &amp;nbsp;Provide test data in the form of a datastep, and what the ouptut should look like. &amp;nbsp;Why for instance would you want to create a whole set of empty varaibles - thats just a waste of disc space. &amp;nbsp;If you need to create something which matches an output specs, then create a template dataset:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create DS_TEMPLATE
    (VAR1 char(200),
     VAR2 num);
quit;&lt;/PRE&gt;
&lt;P&gt;Then set that with your data:&lt;/P&gt;
&lt;PRE&gt;data want;
  set ds_template have;
run;&lt;/PRE&gt;
&lt;P&gt;This will mean all variables in your template are in the output, blank where not present.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387274#M92843</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-11T09:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387275#M92844</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; said, you don't need macros to initialize some variables in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines;
input x1 X2 X3 $;
cards;
1 2 3
4 5 6
7 8 9
run;

data inits;
	set test;
	/* create a new column */
	attrib x4 format=4. informat=4.;
	
	/* Reinitialize x2 - x3 */
	if _N_=2 then call missing(of x2--x3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Aug 2017 09:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387275#M92844</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-08-11T09:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Initialize some variables of datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387280#M92846</link>
      <description>call missing' what's i'm searching for, thanks a lot &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30622"&gt;@gamotte&lt;/a&gt;</description>
      <pubDate>Fri, 11 Aug 2017 10:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Initialize-some-variables-of-datasets/m-p/387280#M92846</guid>
      <dc:creator>amager</dc:creator>
      <dc:date>2017-08-11T10:13:07Z</dc:date>
    </item>
  </channel>
</rss>

