<?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: Import .txt file of Survey Data into SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Import-txt-file-of-Survey-Data-into-SAS/m-p/11418#M1351</link>
    <description>that sounds like a commercial service that should have been commissioned/provided along with the data.&lt;BR /&gt;
&lt;BR /&gt;
For variable-coding you would want to create cntlin= data set for proc format. For re-labelling columns you would want  to generate the "variable = 'label' " text for proc datasets. &lt;BR /&gt;
&lt;BR /&gt;
There are probably features in the data that help you recognise the separate types of data/information. &lt;BR /&gt;
Use these criteria to create data sets from which you can build the relevant metadata with code like : [pre]&lt;BR /&gt;
%let infile = your.survey.asc ;&lt;BR /&gt;
data yourLib.data_data_part( label="data loaded %now")&lt;BR /&gt;
     yourLib.label_metadata( label="from &amp;amp;infile" keep= name label )&lt;BR /&gt;
     yourLib.variable_codes( label="&amp;amp;infile var codes" keep= name value label type )&lt;BR /&gt;
     ;&lt;BR /&gt;
   infile "&amp;amp;infile" .......................... ;&lt;BR /&gt;
.................&lt;BR /&gt;
   if {criteria defines variable label} then output yourLib.label_metadata ;&lt;BR /&gt;
   else&lt;BR /&gt;
   if {criteria defines variable codes} then output yourLib.variable_codes ;&lt;BR /&gt;
   else   &lt;BR /&gt;
   if {criteria defines data } then output yourLib.data_data_part ;&lt;BR /&gt;
run;[/pre] That is just schematic... What follows is code you might use for building and applying variable labels from label metadata [pre]&lt;BR /&gt;
 proc sql noprint ;&lt;BR /&gt;
  select trim(name) !! '=' !! quote(trim(label))&lt;BR /&gt;
     into :labelling      separated by '  '&lt;BR /&gt;
     from label_metadata( keep= name label ) &lt;BR /&gt;
   ;&lt;BR /&gt;
quit;&lt;BR /&gt;
proc datasets library =yourLib nolist ;&lt;BR /&gt;
   modify  data_data_part ;&lt;BR /&gt;
      Label &amp;amp;label_metadata ;&lt;BR /&gt;
   run;&lt;BR /&gt;
quit;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Good Luck&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
    <pubDate>Fri, 18 Apr 2008 12:37:52 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-18T12:37:52Z</dc:date>
    <item>
      <title>Import .txt file of Survey Data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-txt-file-of-Survey-Data-into-SAS/m-p/11417#M1350</link>
      <description>I have a txt file (.asc) of Survey data (more than 100 variables Q1-Q100), with variable label and variable coding list as separated parts in the txt file (.asc).&lt;BR /&gt;
&lt;BR /&gt;
Is there any systematic methods to read this file? I mean, label all variables, and coding each variable in a systematic way rather than re_label and code (proc format) each variable one by one in SAS?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Wed, 16 Apr 2008 19:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-txt-file-of-Survey-Data-into-SAS/m-p/11417#M1350</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-16T19:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Import .txt file of Survey Data into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-txt-file-of-Survey-Data-into-SAS/m-p/11418#M1351</link>
      <description>that sounds like a commercial service that should have been commissioned/provided along with the data.&lt;BR /&gt;
&lt;BR /&gt;
For variable-coding you would want to create cntlin= data set for proc format. For re-labelling columns you would want  to generate the "variable = 'label' " text for proc datasets. &lt;BR /&gt;
&lt;BR /&gt;
There are probably features in the data that help you recognise the separate types of data/information. &lt;BR /&gt;
Use these criteria to create data sets from which you can build the relevant metadata with code like : [pre]&lt;BR /&gt;
%let infile = your.survey.asc ;&lt;BR /&gt;
data yourLib.data_data_part( label="data loaded %now")&lt;BR /&gt;
     yourLib.label_metadata( label="from &amp;amp;infile" keep= name label )&lt;BR /&gt;
     yourLib.variable_codes( label="&amp;amp;infile var codes" keep= name value label type )&lt;BR /&gt;
     ;&lt;BR /&gt;
   infile "&amp;amp;infile" .......................... ;&lt;BR /&gt;
.................&lt;BR /&gt;
   if {criteria defines variable label} then output yourLib.label_metadata ;&lt;BR /&gt;
   else&lt;BR /&gt;
   if {criteria defines variable codes} then output yourLib.variable_codes ;&lt;BR /&gt;
   else   &lt;BR /&gt;
   if {criteria defines data } then output yourLib.data_data_part ;&lt;BR /&gt;
run;[/pre] That is just schematic... What follows is code you might use for building and applying variable labels from label metadata [pre]&lt;BR /&gt;
 proc sql noprint ;&lt;BR /&gt;
  select trim(name) !! '=' !! quote(trim(label))&lt;BR /&gt;
     into :labelling      separated by '  '&lt;BR /&gt;
     from label_metadata( keep= name label ) &lt;BR /&gt;
   ;&lt;BR /&gt;
quit;&lt;BR /&gt;
proc datasets library =yourLib nolist ;&lt;BR /&gt;
   modify  data_data_part ;&lt;BR /&gt;
      Label &amp;amp;label_metadata ;&lt;BR /&gt;
   run;&lt;BR /&gt;
quit;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Good Luck&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Fri, 18 Apr 2008 12:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-txt-file-of-Survey-Data-into-SAS/m-p/11418#M1351</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-18T12:37:52Z</dc:date>
    </item>
  </channel>
</rss>

