<?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 Require only 2 variables to populate in SAS output in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251023#M6736</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I need a SAS program which extract only two variables from a dataset (.dat, .txt or .cum file) that has more than 30 variable data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example: An input .dat file contains 25 variables. However i want to pull only the 18th and 22nd variable in my SAS output file. Condition is I dont want to define all 25 variables in my SAS program. Only the 2 variable names, length and position should be mentioned in program.&lt;/P&gt;&lt;P&gt;Basically, I need this program for a QC purpose wherein - if one variable has a value, then the second should be Blank. If both values are present then such data is of interest. Its a kind of filter that is required. I can use the IF and ELSE statement to populate or delete the data in output. However not sure how to filter the larger data into only area of interest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample .dat file.&lt;/P&gt;&lt;P&gt;Kindly request to provide a solution for my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2016 05:25:10 GMT</pubDate>
    <dc:creator>dhaha001</dc:creator>
    <dc:date>2016-02-19T05:25:10Z</dc:date>
    <item>
      <title>Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251023#M6736</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I need a SAS program which extract only two variables from a dataset (.dat, .txt or .cum file) that has more than 30 variable data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Example: An input .dat file contains 25 variables. However i want to pull only the 18th and 22nd variable in my SAS output file. Condition is I dont want to define all 25 variables in my SAS program. Only the 2 variable names, length and position should be mentioned in program.&lt;/P&gt;&lt;P&gt;Basically, I need this program for a QC purpose wherein - if one variable has a value, then the second should be Blank. If both values are present then such data is of interest. Its a kind of filter that is required. I can use the IF and ELSE statement to populate or delete the data in output. However not sure how to filter the larger data into only area of interest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a sample .dat file.&lt;/P&gt;&lt;P&gt;Kindly request to provide a solution for my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 05:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251023#M6736</guid>
      <dc:creator>dhaha001</dc:creator>
      <dc:date>2016-02-19T05:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251038#M6737</link>
      <description>&lt;P&gt;Import all variables in the DATA step (run PROC IMPORT and get the resulting DATA step from the log) and use KEEP (either as statement or KEEP= option in the output dataset) to only keep the variables you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you do this? Because it is easier to maintain in the future when the input file structure changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might get away with pointers in case the input file has fixed columns.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 07:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251038#M6737</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-02-19T07:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251044#M6738</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length second fourth $ 100;
input;
second=scan(_infile_,2,',','m');
fourth=scan(_infile_,4,',','m');
datalines;
as,as,as,,
ds,,sd,sd
,dsd,,sds,
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 07:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251044#M6738</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-19T07:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251050#M6739</link>
      <description>Hi KurtBremser,&lt;BR /&gt;&lt;BR /&gt;Many thanks for your reply. I wanted a standard program to be used across&lt;BR /&gt;many studies. That's the reason i don't want to define all variable names&lt;BR /&gt;in program. Do we have any specific program which pulls only required&lt;BR /&gt;variables from mentioning variable position.&lt;BR /&gt;&lt;BR /&gt;Kindly assist me in completing this project. If you could provide any&lt;BR /&gt;program that would be great. This platform is really helpful for users like&lt;BR /&gt;me.&lt;BR /&gt;&lt;BR /&gt;Thanks again,&lt;BR /&gt;Harsha&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Fri, 19 Feb 2016 08:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251050#M6739</guid>
      <dc:creator>dhaha001</dc:creator>
      <dc:date>2016-02-19T08:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251069#M6740</link>
      <description>&lt;P&gt;Several question are raised here:&lt;/P&gt;
&lt;P&gt;- You posts contain no example data, no attachments.&lt;/P&gt;
&lt;P&gt;- What is this data file you talk about, is it fixed width, delimited, database file etc.&lt;/P&gt;
&lt;P&gt;- Why do you want to only read a certain couple of variables - not just once, but apparently many times across differing data, this sounds to me like you have a systematic problem with your data transfers which needs to be fixed rather than trying to handle it like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To my mind either the vendor for the data should alter their steps, so you get data in the way you want, or you import all the data into a repository and then extract the data you want from their. &amp;nbsp;Whilst there are methods which can extract parts of the data as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;has shown, what if those columns are not in 4? &amp;nbsp;Or they are, but next time they are not etc. &amp;nbsp;Simply put the process of data transfer should be a) agreed upon by sender and recipient - and documented! &amp;nbsp;b) programs written to import the data based on the agreement c) validated throughout. &amp;nbsp;Following on from this "data transfer" procedure, you can then set to working on stage two, identifying the data you want to keep - logically by using the SAS metadata on the files, or by a documented process baased on the previous documentation of the data transfer. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 09:43:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251069#M6740</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-19T09:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Require only 2 variables to populate in SAS output</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251776#M6774</link>
      <description>&lt;P&gt;Download the macro in this thread &lt;A href="https://communities.sas.com/message/210551#210551" target="_blank"&gt;https://communities.sas.com/message/210551#210551&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to define an empty data set as described in the header of the macro as the model for what fields are to be read from your file(s).&amp;nbsp; Like named fields, ignoring case, will be read using the same INFORMAT data type etc.&amp;nbsp; The order of the columns does not matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 14:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Require-only-2-variables-to-populate-in-SAS-output/m-p/251776#M6774</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-23T14:37:33Z</dc:date>
    </item>
  </channel>
</rss>

