<?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: Creating a dataset if I have a dataset of field names and values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457566#M116014</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114942"&gt;@sschleede&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I'm assuming this is only sample data and you're after a generic solution which works for any number of columns and rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To fully automate this you would need additional information like data type (num or char), length and at least for dates also a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is as it is then what you could do is to first create a text file (data _null_ with put statements) and then convert this text file to a SAS table using Proc Import (=use SAS to guess and assign the missing information like data type).&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 22:53:53 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-04-25T22:53:53Z</dc:date>
    <item>
      <title>Creating a dataset if I have a dataset of field names and values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457535#M116009</link>
      <description>&lt;P&gt;I am programming in SAS 9.4 for Windows and reading a PDF document which has variable labels with values. It looks something like:&lt;/P&gt;&lt;P&gt;Name: Sue&lt;/P&gt;&lt;P&gt;Today's Date: 04/25/2018&lt;/P&gt;&lt;P&gt;Age: 54&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been able to read the PDF document and get a dataset with 3 records&amp;nbsp;that looks like:&lt;/P&gt;&lt;P&gt;FieldName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values&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; labels&lt;/P&gt;&lt;P&gt;Name&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; Sue&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name&lt;/P&gt;&lt;P&gt;Todays_Date&amp;nbsp;&amp;nbsp;&amp;nbsp; 04/25/2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Today's Date&lt;/P&gt;&lt;P&gt;Age&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 54&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Age&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create&amp;nbsp;a dataset with 1 record that looks like:&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Todays_Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Age&lt;/P&gt;&lt;P&gt;Sue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04/25/2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 54&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for ideas on how to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried writing code that used macros but the macro is just putting in the line FieldName = values instead of the 3 lines&lt;/P&gt;&lt;P&gt;Name = values, Todays_Date = values and Age = 54:&lt;/P&gt;&lt;PRE&gt;data Have;
	length FieldName $ 20 values $ 20 labels $ 20;
	FieldName = 'Name';
	values = 'Sue';
	labels = 'Name';
	output;
	FieldName = 'Todays_Date';
	values = '04/25/2018';
	labels = "Today's Date";
	output;
	FieldName = 'Age';
	values = '54';
	labels = 'Age';
	output;
run;

%macro Assign(FN, Value, Labels);
	&amp;amp;FN. = &amp;amp;Value.;
	%put &amp;amp;FN.;
	%put &amp;amp;Value.;
%mend;

data Want;
	set Have;
	%Assign(FieldName, values, labels);
run;

proc print data = Have;
run;

proc print data = Want;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Apr 2018 21:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457535#M116009</guid>
      <dc:creator>sschleede</dc:creator>
      <dc:date>2018-04-25T21:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset if I have a dataset of field names and values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457566#M116014</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114942"&gt;@sschleede&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I'm assuming this is only sample data and you're after a generic solution which works for any number of columns and rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To fully automate this you would need additional information like data type (num or char), length and at least for dates also a format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is as it is then what you could do is to first create a text file (data _null_ with put statements) and then convert this text file to a SAS table using Proc Import (=use SAS to guess and assign the missing information like data type).&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 22:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457566#M116014</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-04-25T22:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset if I have a dataset of field names and values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457567#M116015</link>
      <description>&lt;P&gt;This make a set that looks like your shown output:&lt;/P&gt;
&lt;PRE&gt;proc transpose data=have out=want (drop=_name_);
id fieldname;
var values;
run;&lt;/PRE&gt;
&lt;P&gt;However due to the way Transpose uses ID variables this would not be very extendable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also this does not change any variable types, so the data and age still strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PDF is a poor data interchange medium. If you have access to Adobe Acrobat Pro you might try selecting the data in that program and then using the export to file feature to create something bit more amenable.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 22:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457567#M116015</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-25T22:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset if I have a dataset of field names and values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457847#M116135</link>
      <description>&lt;P&gt;Complete agreement on PDF being very bad for data transfer, but it is what we have. We are working on reading the XML files that come with the PDFs in parallel. But, they have their own set of problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Proc Transpose worked like a charm. I will need a second data step to structure all the data (data types, labels, etc.), but this gets the data roughly right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did go down a couple of other paths but they were very convoluted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 17:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457847#M116135</guid>
      <dc:creator>sschleede</dc:creator>
      <dc:date>2018-04-26T17:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a dataset if I have a dataset of field names and values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457849#M116137</link>
      <description>&lt;P&gt;Writing out to file and reading back in was another good alternative.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Apr 2018 17:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-dataset-if-I-have-a-dataset-of-field-names-and-values/m-p/457849#M116137</guid>
      <dc:creator>sschleede</dc:creator>
      <dc:date>2018-04-26T17:58:37Z</dc:date>
    </item>
  </channel>
</rss>

