<?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: Reading All variables through INPUT statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38609#M7764</link>
    <description>Regarding the first DATA step in the previous post, I believe you want to use the SAS function (new with v9) COUNTW instead of INDEXC, such as:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile datalines dsd dlm='|';&lt;BR /&gt;
input;&lt;BR /&gt;
call symput('ANTVAR',cat(countw(_infile_,'|')));&lt;BR /&gt;
stop;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1|2|3|4|5&lt;BR /&gt;
run;&lt;BR /&gt;
%put Survey Says?  Input &amp;amp;antvar variables;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards, &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Wed, 13 Aug 2008 16:13:52 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2008-08-13T16:13:52Z</dc:date>
    <item>
      <title>Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38606#M7761</link>
      <description>Hello All,&lt;BR /&gt;
Here is the issue: I have a pipe delimited TXT file which has around 200 variables. Iam reading the file using INFILE statement in a DATA STEP, I want to read ALL the variables without specifying the variable names in the INPUT statement, do we have any option in SAS to do that?&lt;BR /&gt;
&lt;BR /&gt;
PS: I dont want to use PROC IMPORT in this case due to some character constraints.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Bob</description>
      <pubDate>Tue, 12 Aug 2008 17:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38606#M7761</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-12T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38607#M7762</link>
      <description>One technique of several - use a DATA step and code an INPUT; statement (no variables listed).  Then use the _INFILE_ variable within a DO/END loop to parse your individual fields with the SCAN function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 12 Aug 2008 19:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38607#M7762</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-08-12T19:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38608#M7763</link>
      <description>If you want to do something dynamic without individual coding for each variable, I think you first have to determine how many variables there are in the file, and us this information either to specify a array or to create a macro %DO loop when reading the file. Array example:&lt;BR /&gt;
&lt;BR /&gt;
data dat;&lt;BR /&gt;
	infile '~/data.dat';&lt;BR /&gt;
	input;&lt;BR /&gt;
	call symput('ANTVAR',left(put(indexc(_infile_,'|') + 1,3.)));&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data dat;&lt;BR /&gt;
	infile '~/data.dat' dlm='|';&lt;BR /&gt;
	array dynvar(*) dynvar1 - dynvar&amp;amp;ANTVAR.;&lt;BR /&gt;
	input dynvar(*);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 13 Aug 2008 11:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38608#M7763</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-13T11:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38609#M7764</link>
      <description>Regarding the first DATA step in the previous post, I believe you want to use the SAS function (new with v9) COUNTW instead of INDEXC, such as:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile datalines dsd dlm='|';&lt;BR /&gt;
input;&lt;BR /&gt;
call symput('ANTVAR',cat(countw(_infile_,'|')));&lt;BR /&gt;
stop;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1|2|3|4|5&lt;BR /&gt;
run;&lt;BR /&gt;
%put Survey Says?  Input &amp;amp;antvar variables;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards, &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 13 Aug 2008 16:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38609#M7764</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-08-13T16:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38610#M7765</link>
      <description>hi,&lt;BR /&gt;
i am not getting proper output.&lt;BR /&gt;
&lt;BR /&gt;
data is at : C:\Documents and Settings\pavan\Desktop\inf.txt&lt;BR /&gt;
&lt;BR /&gt;
pavan*25*m&lt;BR /&gt;
ramu*12*m&lt;BR /&gt;
laxmi*78*f&lt;BR /&gt;
rani*16*f&lt;BR /&gt;
&lt;BR /&gt;
code is:&lt;BR /&gt;
&lt;BR /&gt;
data dat;&lt;BR /&gt;
infile 'C:\Documents and Settings\pavan\Desktop\inf.txt';&lt;BR /&gt;
input;&lt;BR /&gt;
call symput('ANTVAR',left(put(indexc(_infile_,'*')+1,3.)));&lt;BR /&gt;
stop;&lt;BR /&gt;
run;&lt;BR /&gt;
%put &amp;amp;ANTVAR;&lt;BR /&gt;
&lt;BR /&gt;
data dat;&lt;BR /&gt;
infile 'C:\Documents and Settings\pavan\Desktop\inf.txt' dlm='*';&lt;BR /&gt;
array dynvar(*) dynvar1 - dynvar&amp;amp;ANTVAR.;&lt;BR /&gt;
input dynvar(*);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
i am getting 7 variables. instead of 3 variables.&lt;BR /&gt;
&lt;BR /&gt;
help me !

Message was edited by: pavan</description>
      <pubDate>Thu, 14 Aug 2008 14:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38610#M7765</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-08-14T14:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38611#M7766</link>
      <description>Please read my most recent reply - the function INDEXC was suggested where it should be a different function to determine the number of variables.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 14 Aug 2008 15:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38611#M7766</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-08-14T15:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38612#M7767</link>
      <description>Sorry, I don't what I was thinking of. I meant to suggest countc, but as Scott says counw is a bit neater (just make sure to remove the +1 part from my example).&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 14 Aug 2008 15:26:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38612#M7767</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-14T15:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38613#M7768</link>
      <description>what is the need of cat fun. in this statement. explain?&lt;BR /&gt;
&lt;BR /&gt;
call symput('ANTVAR',cat(countw(_infile_,'|')));</description>
      <pubDate>Fri, 15 Aug 2008 06:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38613#M7768</guid>
      <dc:creator>Pavan_SAS</dc:creator>
      <dc:date>2008-08-15T06:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38614#M7769</link>
      <description>Just have a look at the online help:&lt;BR /&gt;
"The CAT function removes leading and trailing blanks from numeric arguments after it formats the numeric value with the BEST. format."&lt;BR /&gt;
&lt;BR /&gt;
I suggest using call symput&lt;B&gt;x&lt;/B&gt; to create the macro variable, making the call of the cat function redundant.</description>
      <pubDate>Fri, 15 Aug 2008 06:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38614#M7769</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2008-08-15T06:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38615#M7770</link>
      <description>Oooo - kewl!  Never used SYMPUTX.  Thanks much for the tip!</description>
      <pubDate>Fri, 15 Aug 2008 12:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38615#M7770</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-08-15T12:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reading All variables through INPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38616#M7771</link>
      <description>since this is just to investigate the content (like lining up the delimiters), I tend to type as little as possible:[pre]   data ; &lt;BR /&gt;
      length col1-col300 $20 ;&lt;BR /&gt;
      infile "your input file" dsd lrecl=20000 ;&lt;BR /&gt;
      input col: ;&lt;BR /&gt;
   run ;[/pre]That provides a quick version of the data that i can examine. &lt;BR /&gt;
My preferred viewer in these situations is FSView. It allows you to try data conversions using input() and other functions as well as data formatting ~ all dynamically, and with a facility to keep these interpretations until the next time;-)&lt;BR /&gt;
With luck you won't be running SAS on E.G. where FSView is not possible.  &lt;BR /&gt;
&lt;BR /&gt;
Good luck&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Sun, 17 Aug 2008 08:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-All-variables-through-INPUT-statement/m-p/38616#M7771</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2008-08-17T08:15:31Z</dc:date>
    </item>
  </channel>
</rss>

