<?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: VTYPE values in Macro or Data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611580#M178264</link>
    <description>&lt;P&gt;If you look at any of these data sets, you will see that the values of variable TYP are capitalized. So&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ="n" ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will always fail. You need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ='N' ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, you want&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ="N" then new_&amp;amp;var=put(&amp;amp;var,8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will eliminate the other error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2019 15:06:30 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-12-13T15:06:30Z</dc:date>
    <item>
      <title>VTYPE values in Macro or Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611573#M178257</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create variables to convert value from Numeric to Character depending on VTYPE values but seems things are not working and log is having issues.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me out on what is going wrong ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is log issues:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;36 %check(name);&lt;BR /&gt;MLOGIC(CHECK): Beginning execution.&lt;BR /&gt;MLOGIC(CHECK): Parameter VAR has value name&lt;BR /&gt;MPRINT(CHECK): data check;&lt;BR /&gt;MPRINT(CHECK): set sashelp.class;&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to name&lt;BR /&gt;MPRINT(CHECK): typ = vtype(name);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to name&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to name&lt;BR /&gt;NOTE: Line generated by the invoked macro "CHECK".&lt;BR /&gt;36 data check; set sashelp.class; typ = vtype(&amp;amp;var); if typ="n" then new_&amp;amp;var=put(&amp;amp;var,best.); else new_&amp;amp;var=strip(&amp;amp;var); run;&lt;BR /&gt;_____&lt;BR /&gt;484&lt;BR /&gt;NOTE 484-185: Format $BEST was not found or could not be loaded.&lt;/P&gt;&lt;P&gt;MPRINT(CHECK): if typ="n" then new_name=put(name,best.);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to name&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to name&lt;BR /&gt;MPRINT(CHECK): else new_name=strip(name);&lt;BR /&gt;MPRINT(CHECK): run;&lt;/P&gt;&lt;P&gt;The SAS System 08:48 Friday, December 13, 2019&lt;/P&gt;&lt;P&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.CHECK has 19 observations and 7 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.CHECK increased size by 100.00 percent.&lt;BR /&gt;Compressed is 2 pages; un-compressed would require 1 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK): Ending execution.&lt;BR /&gt;37 %check(age);&lt;BR /&gt;MLOGIC(CHECK): Beginning execution.&lt;BR /&gt;MLOGIC(CHECK): Parameter VAR has value age&lt;BR /&gt;MPRINT(CHECK): data check;&lt;BR /&gt;MPRINT(CHECK): set sashelp.class;&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to age&lt;BR /&gt;MPRINT(CHECK): typ = vtype(age);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to age&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to age&lt;BR /&gt;MPRINT(CHECK): if typ="n" then new_age=put(age,best.);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to age&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to age&lt;BR /&gt;MPRINT(CHECK): else new_age=strip(age);&lt;BR /&gt;MPRINT(CHECK): run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;37:1&lt;BR /&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.CHECK has 19 observations and 7 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.CHECK increased size by 100.00 percent.&lt;BR /&gt;Compressed is 2 pages; un-compressed would require 1 pages.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK): Ending execution.&lt;BR /&gt;38 %check(height);&lt;BR /&gt;MLOGIC(CHECK): Beginning execution.&lt;BR /&gt;MLOGIC(CHECK): Parameter VAR has value height&lt;BR /&gt;MPRINT(CHECK): data check;&lt;BR /&gt;MPRINT(CHECK): set sashelp.class;&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to height&lt;BR /&gt;MPRINT(CHECK): typ = vtype(height);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to height&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to height&lt;BR /&gt;MPRINT(CHECK): if typ="n" then new_height=put(height,best.);&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to height&lt;BR /&gt;SYMBOLGEN: Macro variable VAR resolves to height&lt;BR /&gt;MPRINT(CHECK): else new_height=strip(height);&lt;BR /&gt;MPRINT(CHECK): run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;38:1&lt;BR /&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.CHECK has 19 observations and 7 variables.&lt;BR /&gt;NOTE: Compressing data set WORK.CHECK increased size by 100.00 percent.&lt;BR /&gt;Compressed is 2 pages; un-compressed would require 1 pages.&lt;BR /&gt;The SAS System 08:48 Friday, December 13, 2019&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK): Ending execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check (var);
data check;
set sashelp.class;
typ = vtype(&amp;amp;var);
if typ="n" then 
new_&amp;amp;var=put(&amp;amp;var,best.);
else new_&amp;amp;var=strip(&amp;amp;var);
run;
%mend;
options symbolgen mlogic mprint;
%check(name);
%check(age);
%check(height);
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 14:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611573#M178257</guid>
      <dc:creator>draroda</dc:creator>
      <dc:date>2019-12-13T14:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: VTYPE values in Macro or Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611576#M178260</link>
      <description>&lt;P&gt;A data step compiles ALL of the code you give it. Even the part inside an branch that can never end up executing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your macro is not really very useful as presented but let's use it as an example of ways to handle this type of issue.&amp;nbsp; One way is to just write code that does not depend on knowing the variables type before the data step starts running.&amp;nbsp; For example by using VVALUE() function to get the formatted value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
  set sashelp.class;
  new_NAME=vvalue(NAME);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other is to find out the type and use that to drive MACRO logic that generates different code for the data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.class;
  call symputx('typ',vtype(NAME));
  stop;
run;
data check;
  set sashelp.class;
%if N=&amp;amp;typ %then %do;
  new_NAME=put(NAME,best32.);
%end;
%else %do;
  new_NAME=strip(NAME);
%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611576#M178260</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-13T15:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: VTYPE values in Macro or Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611580#M178264</link>
      <description>&lt;P&gt;If you look at any of these data sets, you will see that the values of variable TYP are capitalized. So&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ="n" ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will always fail. You need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ='N' ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, you want&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if typ="N" then new_&amp;amp;var=put(&amp;amp;var,8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will eliminate the other error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2019 15:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/611580#M178264</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-13T15:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: VTYPE values in Macro or Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/750465#M236060</link>
      <description>Moved to a new thread</description>
      <pubDate>Fri, 25 Jun 2021 15:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VTYPE-values-in-Macro-or-Data-step/m-p/750465#M236060</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-25T15:36:56Z</dc:date>
    </item>
  </channel>
</rss>

