<?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: Variable types in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145741#M261950</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would I win any money betting that these data sets were built using Proc Import from Excel?&lt;/P&gt;&lt;P&gt;You'll not be able to "change" the type in the existing data set. You might create a new variable using a data step and input on the old variable and overwrite your existing set with the new:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data dataset1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewVar7 = input(var7, best8.); /* or if the values are longer then bestx.*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you may get warning messages for the sets var7 is alread numeric.&lt;/P&gt;&lt;P&gt;Or go back and control how the original data is created.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 May 2014 23:12:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-05-05T23:12:06Z</dc:date>
    <item>
      <title>Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145740#M261949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a numer of datasets (30 approx). with a variable var7. Variable var7 (actually numeric)&amp;nbsp; is appearing as numeric in some of the datasets and character in the remaining datasets. Is there a simple way to make it numeric in all of the datasets?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 May 2014 21:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145740#M261949</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-05T21:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145741#M261950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would I win any money betting that these data sets were built using Proc Import from Excel?&lt;/P&gt;&lt;P&gt;You'll not be able to "change" the type in the existing data set. You might create a new variable using a data step and input on the old variable and overwrite your existing set with the new:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data dataset1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewVar7 = input(var7, best8.); /* or if the values are longer then bestx.*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you may get warning messages for the sets var7 is alread numeric.&lt;/P&gt;&lt;P&gt;Or go back and control how the original data is created.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 May 2014 23:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145741#M261950</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-05T23:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145742#M261951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to keep the name var7 do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data dataset1;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set dataset1 (rename = (var7 = OldVar7)) ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Var7 = input(OldVar7, ?? best.); /* specify length if any number has more than 12 significant digits */&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Drop OldVar7 ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If, as ballardw guesses, these files are coming from Excel this problem can occur if there are a series of blank cells for the column in the first few records.&amp;nbsp; One palliative is to insert an additional dummy row ( line 2) in Excel, consisting of zeros, to force the type recognition.&amp;nbsp; You can then drop the row in SAS using the dataset option firstobs=2.d&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Richard&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Richard Carson&#xD;
Added the ?? modifier to suppress warning messages in Import() .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 01:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145742#M261951</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-05-06T01:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145743#M261952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks ballard&lt;/SPAN&gt;W solution and &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Richard&lt;/SPAN&gt; for your input on this. Yes, that is correct I imported csv files and having problems in manipulating variables. Var7 is supposed to be numeric in my all datasets but I don't know what went wrong while importing files, may be I missed something.&amp;nbsp; Now I am looking for some macro that&amp;nbsp; can add all the datasets&amp;nbsp; and fix var7 at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 01:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145743#M261952</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-06T01:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145744#M261953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is something to try: inserting that row of zeros in the CSV file before importing to SAS.&amp;nbsp; You could wrap this in a macro and run the macro for each file.&amp;nbsp; Assuming the first column is a character record id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Filename csvfile "&lt;EM&gt;insert fully referenced csv filename here&lt;/EM&gt;" ;&lt;/P&gt;&lt;P&gt;Filename csvfile2 "&lt;EM&gt;insert another fully referenced csv filename here&lt;/EM&gt;" ; /* for modified csv input */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data _Null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Infile csvfile ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* you might need a lrecl= option here */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If _N_ = 1 then &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Put _Infile_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Put "Dummy, 0, 0, 0, 0, 0, 0, 0" ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Put _Infile_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Run ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc import ... ; /* use csvfile2 for import */&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set have (firstobs = 2) ;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 01:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145744#M261953</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-05-06T01:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145745#M261954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I applied the syntax above and getting following message. Any suggestions please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile CSVFILE is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filename=C:\Users\Awan\Desktop\file1.csv,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RECFM=V,LRECL=256,File Size (bytes)=26742808,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Modified=April 30, 2014 12:04:32 o'cloc,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create Time=May 06, 2014 14:48:49 o'clock&lt;/P&gt;&lt;P&gt;ERROR: Put _INFILE_ executed before INPUT statement for INFILE&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C:\Users\Awan\Desktop\file1.csv.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 19:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145745#M261954</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-06T19:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145746#M261955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My bad - I do not have a SAS implementation at home to test code.&amp;nbsp; This may fix the problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data _Null_ ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Infile csvfile ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* you might need a lrecl= option here */&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; File csvfile2 ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Input ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If _N_ = 1 then&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Put _Infile_ ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Put "Dummy, 0, 0, 0, 0, 0, 0, 0" ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Put _Infile_ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Run ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Proc import ... ; /* use csvfile2 for import */&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data have ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set have (firstobs = 2) ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 21:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145746#M261955</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-05-06T21:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Variable types</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145747#M261956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Richard - working perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 21:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-types/m-p/145747#M261956</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-06T21:41:00Z</dc:date>
    </item>
  </channel>
</rss>

