<?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: mixup with value labels after import from SPSS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631860#M187245</link>
    <description>&lt;P&gt;Can you provide more details.&amp;nbsp; Your first step should create WORK.ALL_DR dataset.&amp;nbsp; Show the PROC CONTENTS output. (preferable as text instead of photographs.)&amp;nbsp; What is the actual name of the variable you are referring to as&amp;nbsp;&lt;SPAN&gt;"marital status"&amp;nbsp;?&amp;nbsp; What is it type? Numeric or Character?&amp;nbsp; Did PROC IMPORT attach a format to it?&amp;nbsp; What is that formats name?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS stores format definitions independently from the variables.&amp;nbsp; And independently from the datasets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In neither step did you tell the procs where to write or find formats.&amp;nbsp; Try being specific about where you want IMPORT to write the format definitions and where PROC EXPORT should look to find format definitions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did it actually create any formats from the value labels?&amp;nbsp; Can you run PROC FORMAT with the FMTLIB option to see what format it created.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did you import any other SPSS files that might have overwritten the format with something else?&amp;nbsp; Did you run an PROC FORMAT statements of your own that might have overwritten the formats.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 13:52:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-03-13T13:52:08Z</dc:date>
    <item>
      <title>mixup with value labels after import from SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631858#M187243</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use Sas mainly when I'm asked to provide files in .sav format because it can handle value labels with import and export of .sav files. However today I noticed something worrisome, after importing and exporting a file using below code the value labels had changed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc import
	file = "file.sav"
	out = all_dr
	dbms = spss
	replace;
run;

proc export
	data = all_dr
	outfile = "file_out.sav"
	dbms=spss
	replace;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an item called "marital status" which looks like this in the original file:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="before.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36844i35FE55933648594E/image-size/large?v=v2&amp;amp;px=999" role="button" title="before.PNG" alt="before.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and after exporting has different value labels:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="after.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36845iAD3F33946B09B0F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="after.PNG" alt="after.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These new value labels come from another item about household status.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something I could do to fix this or is it better to not use Sas for this purpose? In that case I would have to start using SPSS syntax for merging and filtering which I'm not really looking forward too..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 13:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631858#M187243</guid>
      <dc:creator>bouz22</dc:creator>
      <dc:date>2020-03-13T13:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: mixup with value labels after import from SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631860#M187245</link>
      <description>&lt;P&gt;Can you provide more details.&amp;nbsp; Your first step should create WORK.ALL_DR dataset.&amp;nbsp; Show the PROC CONTENTS output. (preferable as text instead of photographs.)&amp;nbsp; What is the actual name of the variable you are referring to as&amp;nbsp;&lt;SPAN&gt;"marital status"&amp;nbsp;?&amp;nbsp; What is it type? Numeric or Character?&amp;nbsp; Did PROC IMPORT attach a format to it?&amp;nbsp; What is that formats name?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS stores format definitions independently from the variables.&amp;nbsp; And independently from the datasets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In neither step did you tell the procs where to write or find formats.&amp;nbsp; Try being specific about where you want IMPORT to write the format definitions and where PROC EXPORT should look to find format definitions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did it actually create any formats from the value labels?&amp;nbsp; Can you run PROC FORMAT with the FMTLIB option to see what format it created.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did you import any other SPSS files that might have overwritten the format with something else?&amp;nbsp; Did you run an PROC FORMAT statements of your own that might have overwritten the formats.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 13:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631860#M187245</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-13T13:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: mixup with value labels after import from SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631879#M187252</link>
      <description>&lt;P&gt;Thank you for the quick reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran the file again after restarting Sas and I only ran above lines of code (proc import/proc export) so no other format statements. That seems to have solved the issue.. I tried running the rest of the code to see if the problem occurred after loading other spss files and then I noticed there is a second variable with exactly the same value labels so I suppose that is where the problem arises.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the original file:&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;MF_MARSTAT&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;MF_MARS.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Marital Status&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;sl_cur_ms&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;SL_CUR1A.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Current marital status&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The labels of these two items are identical so I guess that's where the problem lies, although it only occurs after joining tables and/or loading other SPSS files. Strangely there is nothing in the proc contents of the joined and filtered output file that suggests the labels are different:&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;52 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;sl_cur_ms&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;SL_CUR1A.&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Current marital status&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output of proc fomat, with both the household and the marital status items:&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;TABLE cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;PRE class="batch"&gt; „ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†           
           ‚       FORMAT NAME: SL_CUR1A LENGTH:   22   NUMBER OF VALUES:    5        ‚           
           ‚   MIN LENGTH:   1  MAX LENGTH:  22  DEFAULT LENGTH:  22  FUZZ:        0  ‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚START           ‚END             ‚LABEL  (VER. V7|V8   13MAR2020:15:01:49)‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚               1‚               1‚Single                                  ‚           
           ‚               2‚               2‚With parent(s)                          ‚           
           ‚               3‚               3‚With partner/family                     ‚           
           ‚               4‚               4‚Sheltered living (ggz)                  ‚           
           ‚               5‚               5‚Other                                   ‚           
           Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŒ           
                                                                                                  
                                                                                                  
           „ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†           
           ‚       FORMAT NAME: SL_CUR_  LENGTH:   22   NUMBER OF VALUES:    5        ‚           
           ‚   MIN LENGTH:   1  MAX LENGTH:  22  DEFAULT LENGTH:  22  FUZZ:        0  ‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚START           ‚END             ‚LABEL  (VER. V7|V8   13MAR2020:14:53:40)‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚               1‚               1‚Single                                  ‚           
           ‚               2‚               2‚With parent(s)                          ‚           
           ‚               3‚               3‚With partner/family                     ‚           
           ‚               4‚               4‚Sheltered living (ggz)                  ‚           
           „ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ†           
           ‚       FORMAT NAME: SL_CUR_  LENGTH:   22   NUMBER OF VALUES:    5        ‚           
           ‚   MIN LENGTH:   1  MAX LENGTH:  22  DEFAULT LENGTH:  22  FUZZ:        0  ‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚START           ‚END             ‚LABEL                           (CONT'D)‚           
           ‡ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‰           
           ‚               5‚               5‚Other                                   ‚           
           Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŒ           &lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My apologies for the formatting mess, I don't find the option to get text back to outlined left after pasting the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could I specify where to write the format definitions durint the IMPORT step?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Mar 2020 14:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631879#M187252</guid>
      <dc:creator>bouz22</dc:creator>
      <dc:date>2020-03-13T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: mixup with value labels after import from SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631892#M187258</link>
      <description>&lt;P&gt;Use the FMTLIB option.&amp;nbsp;&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1b08qam0tmo97n1j27xceo6xsrl.htm&amp;amp;docsetVersion=3.2&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p1b08qam0tmo97n1j27xceo6xsrl.htm&amp;amp;docsetVersion=3.2&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will probably want to use a separate format catalog for each SPSS file to avoid collision of format names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like I said, in SAS formats are independent.&amp;nbsp; So SL_CUR1A defines the fact that 1 maps to Single, etc.&amp;nbsp; You are then free to tell SAS which variables you want to use that decode for.&amp;nbsp; So if you have 20 questions that each have the same set of responses instead of making 20 different formats you would define just one and attach it to all 20 variables.&amp;nbsp; SPSS doesn't do that.&amp;nbsp; It stores the "value labels" with each variable's definition.&amp;nbsp; So if you want to have 20 variables use the same set of decodes that information is stored 20 times in the SPSS file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plus in SAS the decode information is NOT stored in the dataset.&amp;nbsp; Only the NAME of the format that is to be used to decode/display that variable is stored. The actual definition (1=Single) is stored in the format definition in a format catalog, a separate file.&amp;nbsp; So when you use the dataset you need to make sure to set the FMTSEARCH system option so that it can find the formats.&amp;nbsp; If the FMTSEARCH option is pointing to the wrong catalog it might not find the format, or it might find a different format that uses the same name.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 15:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/631892#M187258</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-13T15:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: mixup with value labels after import from SPSS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/632369#M187484</link>
      <description>&lt;P&gt;Thank you very much for the detailed explanation Tom, this was very helpful. I now created one library in the beginning of the Sas script and used that same library for all the .sav files I import. If I understand it correctly it will then reuse formats that are the same between two spss files and make new ones for new formats. Before exporting I used FMTSEARCH option and the labels are now coming out correct!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I couldn't figure out at first how to use the FMTLIB statement in proc import but I managed with this link:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=n1h6b01uh0dm2yn1fpq85gjgwcfs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1gy2zfmwphcjen1uyrvkxlaqcq0" target="_blank"&gt;https://documentation.sas.com/?docsetId=acpcref&amp;amp;docsetTarget=n1h6b01uh0dm2yn1fpq85gjgwcfs.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1gy2zfmwphcjen1uyrvkxlaqcq0&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm foreseeing that I will have to keep using Sas to merge and filter SPSS files so I was quite desperate when I noticed this error, I'm happy it's solved now!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 09:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/mixup-with-value-labels-after-import-from-SPSS/m-p/632369#M187484</guid>
      <dc:creator>bouz22</dc:creator>
      <dc:date>2020-03-16T09:38:35Z</dc:date>
    </item>
  </channel>
</rss>

