<?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: Track value of same variable across multiple data steps in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523960#M142432</link>
    <description>&lt;P&gt;Can you clarify what you mean by FLAG?&amp;nbsp; Are you setting a flag variable on the individual records that need to be modified?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by combining the first two steps?&amp;nbsp; Do you mean you want all SSN that were flagged in either of the first two steps or those flagged only in both?&lt;/P&gt;
&lt;P&gt;Are the datasets in each step one observations per SSN?&amp;nbsp; Or are they more complex?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You program was a little convoluted and hard to follow. It seemed to be both read and writing to text files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would probably be easier to separate out the parts that read and write the text files and just concentrate on processing the data as SAS datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why did the code you posted appear to be using GOTO statements to mimic a DO loop? Or possibly to mimic the normal data step iteration over all observations in the input data?&amp;nbsp; Is there some hidden complexity in the data structure? Or is it just written by someone that wasn't familiar with how SAS data steps work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Dec 2018 21:53:59 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-12-31T21:53:59Z</dc:date>
    <item>
      <title>Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523677#M142295</link>
      <description>&lt;P&gt;The attached code processes multiple file types (S, E and D) and corrects bad reporting of SSN data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our ETL process requires file types S, E and D to be run through together.&amp;nbsp; My problem is that S and E will have changes, while D may not.&amp;nbsp; How do I "track" what has happened in preceding data steps for other file types.?&amp;nbsp; Like have a variable "outside" that is updated within these data steps.&amp;nbsp; The above code just covers one year and semester.&amp;nbsp; We will be correcting SSN data to present (where needed).&amp;nbsp; I need to generate a corresponding D "change" file even though nothing has been changed.&amp;nbsp; I am trying to generate a list of changed files that my data tech can process through our edit application to stage data for the ETL.&amp;nbsp; Hope I have explained this well enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any assistance you&amp;nbsp;give to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 17:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523677#M142295</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2018-12-27T17:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523823#M142372</link>
      <description>&lt;P&gt;Can you post sample data and what you expect as result?&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2018 13:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523823#M142372</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-12-29T13:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523831#M142376</link>
      <description>&lt;P&gt;This is pretty vague, and so the only answers I can give are also vague&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;How do I "track" what has happened in preceding data steps for other file types.?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC PRINT will show you what has happened. Or you could store the before and after in a data set for comparison.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Like have a variable "outside" that is updated within these data steps.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Same answer as before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But really, we need a small data set, where you can show us by example exactly what you want.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2018 17:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523831#M142376</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-29T17:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523833#M142377</link>
      <description>&lt;P&gt;Can you simply the question to just the thing that you don't understand?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I need to generate a corresponding D "change" file even though nothing has been changed.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;How are you doing this now?&amp;nbsp; Are you making a dataset with one observation per change?&amp;nbsp; &amp;nbsp;Perhaps you could just add a step like this that will make sure there is at least one observation in the dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  if _n_=1 and final then output;
  set have end=final;&lt;BR /&gt;  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2018 17:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523833#M142377</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-29T17:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523927#M142420</link>
      <description>&lt;P&gt;Good morning all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to thank those who replied to my post.&amp;nbsp; I thought I had attached code to better explained my problem.&lt;/P&gt;&lt;P&gt;Oh well, I've been reading all weekend.&amp;nbsp; I think I have found my answer...%GLOBAL.&amp;nbsp; Will test out today.&lt;/P&gt;&lt;P&gt;Closing this post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy New Year to all.&amp;nbsp; Maybe will "see" ya next year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 14:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523927#M142420</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2018-12-31T14:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523957#M142431</link>
      <description>&lt;P&gt;I thought I was on to my answer, but have struggled all day and gotten no further with resolution to my problem.&amp;nbsp; I will simplify in hopes that you will have an answer.&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; My first data step reads in records from a student demographic file and sorts&amp;nbsp;it with another file that marks ssns&amp;nbsp;needing to be corrected.&amp;nbsp; A flag is set to 'Y' to indicate that the file actually was modified and all records (changed/unchanged) are written out&lt;/P&gt;&lt;P&gt;to a new file containing "changed" in the name.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; My second data step reads in records from a student course file and again sorts&amp;nbsp;it with the file that marks ssns needing to be&lt;/P&gt;&lt;P&gt;corrected.&amp;nbsp; The flag in step #1 is initialized to 'N'.&amp;nbsp; It&amp;nbsp;is set to 'Y' again per verbiage in step #1.&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; My third data step reads in records from a student degree awarded file and again sorts it with the file that marks ssns needing to be corrected.&amp;nbsp; This file may or may not contain the students' ssns corrected in steps #1,2.&amp;nbsp; Not every student in the demographic/course files receive degrees.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I need to know what the flag has been set to in steps #1 and/or&amp;nbsp; #2.&amp;nbsp; This will be used in step #3 to generate a degree file to be processed with the demographic and course files.&amp;nbsp; Our ETL will have problems if all three files are not processed together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is clear enough.&amp;nbsp; If not, I can expand on my explanation.&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 21:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523957#M142431</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2018-12-31T21:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523960#M142432</link>
      <description>&lt;P&gt;Can you clarify what you mean by FLAG?&amp;nbsp; Are you setting a flag variable on the individual records that need to be modified?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by combining the first two steps?&amp;nbsp; Do you mean you want all SSN that were flagged in either of the first two steps or those flagged only in both?&lt;/P&gt;
&lt;P&gt;Are the datasets in each step one observations per SSN?&amp;nbsp; Or are they more complex?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You program was a little convoluted and hard to follow. It seemed to be both read and writing to text files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would probably be easier to separate out the parts that read and write the text files and just concentrate on processing the data as SAS datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why did the code you posted appear to be using GOTO statements to mimic a DO loop? Or possibly to mimic the normal data step iteration over all observations in the input data?&amp;nbsp; Is there some hidden complexity in the data structure? Or is it just written by someone that wasn't familiar with how SAS data steps work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 21:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/523960#M142432</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-31T21:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524021#M142451</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to not have responded sooner.&amp;nbsp; Happy New Year BTW!&amp;nbsp; And...thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct.&amp;nbsp; My code is convoluted.&amp;nbsp; I learned SAS the way my former supervisor taught me way back in 1985.&amp;nbsp; I am the only programmer doing SAS in my office and have not taken time to update my "skills".&amp;nbsp; Have been trying new things today.&amp;nbsp; Thank you for the "prodding".&amp;nbsp; Started a new version of my program.&amp;nbsp; Trying to use loops (i,j,k) to iterate through years, semester, and institutions (in that order).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you increment a loop index if not consecutive numbering?&amp;nbsp; Example of my institution codes are '110','111','120','340'.&amp;nbsp; Is there&amp;nbsp;a way to use an IN('110','111') to update my index.&amp;nbsp; I am attaching my new attempt.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jackie O&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 00:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524021#M142451</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-02T00:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524136#M142496</link>
      <description>&lt;P&gt;Anyone?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible within a DATA STEP to read both an external file and results from a SQL query?&amp;nbsp; I have attached my code.&amp;nbsp; I have two SQL queries.&amp;nbsp; One determines which institutions have to be processed.&amp;nbsp; The second contains SSN changes.&amp;nbsp; The goal:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Out of 46 institutions, process only those with changes found in the first query.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Only process semester and years impacted by the changes( SUM,FALL,SPRING AND 20102011 to 20182019).&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; Output the external files in entirety, but with the SSN changes made.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am certain with all your experiences that you know of a better way.&amp;nbsp;&amp;nbsp;Sometimes I equate posting a question to walking before a&lt;/P&gt;&lt;P&gt;firing squad.&amp;nbsp; I am a bit sensitive.&amp;nbsp; However, Tom opened my eyes to SAS 9.4 and I so thank him.&amp;nbsp; I first learned SAS in 1985 and my coding is antiquated at best.&amp;nbsp; Trying new things with version 2 of this project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 17:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524136#M142496</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-02T17:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524157#M142500</link>
      <description>&lt;P&gt;1) So the first query gets a list of SSN?&amp;nbsp; Which variable contains the SSN?&amp;nbsp; Because the variable you all calling SSN09 is set to NULL on every record.&amp;nbsp; Also what type of variable is SSN09 supposed to be?&amp;nbsp; Normally you would store SSN in a character variable, but your Oracle query is not setting a type for the variable and so I am not sure what type SAS will create for it when you pull it into SAS.&amp;nbsp; Will it be a number or a character string?&lt;/P&gt;
&lt;P&gt;Note no need for a separate PROC SORT step as you can add an ORDER BY clause to your SQL query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE inst_list AS
  SELECT * FROM CONNECTION TO myconn
(SELECT DISTINCT
   institution_code AS inst_code
 , NULL AS ssn09
 , 'A' AS record_type 
 FROM renaeb.ssn_update
 WHERE (COMMENTS &amp;lt;&amp;gt; 'CORRECTED' OR COMMENTS IS NULL)
   AND NEW_SSN IS NOT NULL
)
order by inst_code, ssn09, record_type
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps you meant the second query?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That one appears to be creating two variables with names that look like they should contain SSN values, SSN09 and NEW_SSN.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CREATE TABLE ssn_updates AS
SELECT * FROM CONNECTION TO myconn 
(SELECT
  institution_code AS inst_code
, original_ssn AS ssn09
, new_ssn
, last_name
, first_name
, middle_name
, birthdate
, gender
, 'B' AS record_type 
FROM renaeb.ssn_update
WHERE (COMMENTS &amp;lt;&amp;gt; 'CORRECTED' OR COMMENTS IS NULL)
  AND NEW_SSN IS NOT NULL
)
order by inst_code, ssn09, record_type
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(2)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by PROCESS?&amp;nbsp; What are you trying to do?&amp;nbsp; Are you just changing SSN's and nothing else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you know what semesters?&amp;nbsp; Is that what the DO Loops in the data step are trying to do?&amp;nbsp; Or is that information that you could have pulled from your Oracle table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your DATA steps looks like it is going to read in multiple text files by building the filename up from a number of other fields.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;in_file_name=
  catx('/'
 ,"&amp;amp;parent_path_I"
 ,catt('UDS',record_S,acad_year_2)
 ,sem
 ,catt('I',inst_code,'_S')
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your process should be (1) Generate list of files to read. (2) Read the files into SAS dataset. (3) apply updates (4) write updated files.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any reason to try to combine those four steps into one step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you meant to do something like this, assuming that the included file just contains a subset of a data step to read the data from a file.&amp;nbsp; So just an INPUT statement. With perhaps some LENGTH, LABEL, FORMAT and/or INFORMAT statements as needed to define the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file_list ;
  set inst_list ;
  length yr 8 sem $6 year $8 acad_year_2 $4 in_file_name $200 ;
  do yr = 2010 to 2018 ;
    do sem= 'SUM', 'FALL', 'SPRING';
      acad_year_2 = cats(SUBSTR(put(yr,4.),3) , substr(put(yr+1,4.),3));
      record_S = 'S';
      in_file_name = catx('/', "&amp;amp;parent_path_I" , catt('UDS', record_S, acad_year_2), sem, catt('I', inst, '_S'));
      output;
    end;
  end;
run;


data current ;
  set file_list ;
  INFILE IN FILEVAR = in_file_name LRECL = 250 truncover end=eof;
  do while (not eof);
%INCLUDE '/uds/sas/copylib/UDS_RECORD_S_LAYOUT';
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then update the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=current;
  by inst_code ssn09 ;
run;

data new ;
  merge current (in=in1) ssn_updates(in=in2);
  by inst_code ssn09 ;
  if in2 then ssn09=new_ssn;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if you want to re-create the text files then add a step that does the reverse of the step that read the files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 19:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524157#M142500</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-02T19:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524172#M142508</link>
      <description>Tom,&lt;BR /&gt;Let me digest your suggested code. Got some new things in there as far as I am concerned. Need to research the SUBSTR(PUT...) combination. Also I have concerns bringing all those records across at the same time. Your data step file_list could be as large as 7 million records depending on how many institutions are making SSN changes. Not so much the S demographic records, but the enrollment records which will be another group of files to be corrected later in the program.&lt;BR /&gt;Questions? Your third line of code is just establishing variables and their respective lengths? You create in_file_name in the first data step, but reference it again in the data step current. How is scope not a player here?&lt;BR /&gt;Thank you, Tom&lt;BR /&gt;Jackie O&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 02 Jan 2019 19:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524172#M142508</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-02T19:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524175#M142510</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/249871"&gt;@JackieO&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Tom,&lt;BR /&gt;Let me digest your suggested code. Got some new things in there as far as I am concerned. Need to research the SUBSTR(PUT...) combination. Also I have concerns bringing all those records across at the same time. Your data step file_list could be as large as 7 million records depending on how many institutions are making SSN changes. Not so much the S demographic records, but the enrollment records which will be another group of files to be corrected later in the program.&lt;BR /&gt;Questions? Your third line of code is just establishing variables and their respective lengths? You create in_file_name in the first data step, but reference it again in the data step current. How is scope not a player here?&lt;BR /&gt;Thank you, Tom&lt;BR /&gt;Jackie O&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SUBSTR() operates on character strings. PUT() converts values to strings by applying a format. So PUT(2018,4.) will generate the string '2018',&amp;nbsp; So SUBSTR('2018',3) will pull out the string '18'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;7 Million might have been large in 1985 but is not really a large number of observations today.&amp;nbsp; &amp;nbsp;It is a large number of FILES.&amp;nbsp; Do you really have your data stored in over 7 million little files?&amp;nbsp; Why is the data not in your ORACLE database?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is always a good idea to define your variables instead of letting SAS guess how to define by how you first use them.&amp;nbsp; In addition to a LENGTH (or ATTRIB) statement a good way to define a variable is to SET a dataset that already has that variable in it.&amp;nbsp; The IN_FILE_NAME variable is being read from the FILE_LIST dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 20:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524175#M142510</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-02T20:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524180#M142513</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in SUBSTR(PUT(yr,4.),3)) the 3 means start at that position and stop at the end?&amp;nbsp; Used to have to put how many places to include.&amp;nbsp; I get it.&amp;nbsp; Thank you again!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At&amp;nbsp;most the number of files for a record type (S is demographic)&amp;nbsp;would be #years X #semesters X #institutions (9 X 3 X 46 = 1,242).&amp;nbsp; The table containing the SSN corrections has no academic year or semester within.&amp;nbsp; Institutions often enroll students under assigned numbers if they fail to have a valid SSN.&amp;nbsp; Later on those students do obtain valid SSNs and to report persistence, we need to have those SSNs consistent throughout admission to the institution.&amp;nbsp; So to make things easier on the schools, we search through all our data and update the SSNs for consistency.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We do have most of our data stored in our Oracle database.&amp;nbsp; That is...the data that has passed our edit checks.&amp;nbsp; The in_file_name files contain&amp;nbsp; both the data that passed and the data that failed.&amp;nbsp; So...I go there to make my corrections.&amp;nbsp; I hope to generate a list of the actual files that have been changed so that they can be reprocessed through our ETL and broadcast into our Oracle tables.&amp;nbsp; BTW...the reference to 7 million are the possible number of records and not the possible number of files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to play around with this tonight.&amp;nbsp; I so do appreciate all your help!!!&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 21:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524180#M142513</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-02T21:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524187#M142516</link>
      <description>&lt;P&gt;Sounds like you probably need to sit down and think about what your data flow is and how best to handle this.&lt;/P&gt;
&lt;P&gt;I would want to know answer to a number of things before deciding the right course of action.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why can't you just make the corrections in the Oracle database and not modify the original files?&amp;nbsp; Do they resend then same file multiple times, still with the made-up SSN?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the institutions re-using the made-up SSN numbers for different people over time?&amp;nbsp; That would make fixing them much harder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general it is probably best to structure your database to use your own unique id for each person and treat the SSN as an attribute of the person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Back to your original question.&lt;/P&gt;
&lt;P&gt;So do your list of corrected SSN include INST or not?&amp;nbsp; That is does your update data say that for INST='111' the SSN of '111-22-3333' should really be '999-88-7777'?&amp;nbsp; Or does it just say change all '111-22-3333' to '999-88-7777'?&amp;nbsp; If so that might be easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you figure out how to make the correction then make a SAS dataset that has the corrected data and an observation level FLAG to indiciate that a change was made.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;FILE|INST|SSN|CHANGED
2018F111_S|111|999-88-7777|Y
2018F111_S|112|999-99-7777|N
....&lt;/PRE&gt;
&lt;P&gt;Then you can pull out the list of files that have changed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table updated_files as
select distinct FILE 
from new
where CHANGED='Y'
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And use that to know which files need to be re-written and/or re-run through the ETL process.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 22:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524187#M142516</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-02T22:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524845#M142745</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;All I've done is think about how best to accomplish this. I'll try to explain further.&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;&amp;nbsp;&amp;nbsp; Some, but not all of our data makes it through to our Oracle tables.&amp;nbsp; We have an edit routine that validates data reported and generates element errors found.&amp;nbsp; Those with the highest level "FATAL" are restricted from staging for our Oracle ETL process that populates all of our data tables.&amp;nbsp; These data are held back until these types of errors are corrected.&amp;nbsp; So to answer your question, no.&amp;nbsp; I cannot just correct bad SSNs reported in our Oracle database.&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;&amp;nbsp;&amp;nbsp; We require total replacement files when institutions submit data to us.&amp;nbsp; Yes, we have multiple files submitted by every institution during reporting cycle deadlines.&amp;nbsp; This is why I read in files called "I" files to ensure the most recent data sent.&amp;nbsp; Often the SSN changes go back many years.&amp;nbsp; After a while on Unix, the time stamp just has a year and not month, day and time.&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;&amp;nbsp;&amp;nbsp; Institutions should not be&amp;nbsp;re-assigning numbers.&amp;nbsp; The first 3 digits of assigned SSNs must contain the institution code (such as "110").&amp;nbsp; The other&amp;nbsp;6&amp;nbsp;digits are&amp;nbsp;assigned consecutively.&amp;nbsp; If enough time has transpired, I guess they could re-use.&amp;nbsp; Even the more important to free up an assigned&amp;nbsp;SSN when it gets changed to a valid&amp;nbsp;SSN.&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;&amp;nbsp;&amp;nbsp;The update table does include institution code.&amp;nbsp; I have found that some of these assigned&amp;nbsp;SSNs can actually be a&amp;nbsp;valid SSN if searched system wide.&amp;nbsp; This is why I want to&amp;nbsp;make changes only to data submitted by the given institution.&amp;nbsp; We have an institution code of "146".&amp;nbsp; At another institution say "110" there could well be a valid SSN 146XXXXXX.&amp;nbsp; I have to check both institution code and old SSN&amp;nbsp;prior to changing to the new SSN.&lt;/P&gt;&lt;P&gt;5)&amp;nbsp;&amp;nbsp; A flag on the changed rows would be a good thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OK.&amp;nbsp; I&amp;nbsp;tried your code.&amp;nbsp; Getting errors on the:&lt;/P&gt;&lt;P&gt;INFILE IN FILEVAR = in_file_name LRECL = 250 truncover end=eof;&lt;/P&gt;&lt;P&gt;Expecting something other than in_file_name after the&amp;nbsp;first = sign.&amp;nbsp; Reading to find out why.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for just now getting back with you.&amp;nbsp; Winter storm came through.&amp;nbsp; Work was closed and power was out at my house.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for hanging in there with me.&lt;/P&gt;&lt;P&gt;Jackie O.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 21:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/524845#M142745</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-05T21:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/526475#M143378</link>
      <description>&lt;P&gt;One final reply to Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am almost done with my project(99% complete).&amp;nbsp; Wouldn't have been without your expert advise.&amp;nbsp; I have read more and learned more in the past two weeks than I have in 30 years.&amp;nbsp; I was a bit offended at first, after reading initial responses, but quickly found that you were absolutely right in your comments.&amp;nbsp; I am a better programmer for it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Jackie O&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 20:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/526475#M143378</guid>
      <dc:creator>JackieO</dc:creator>
      <dc:date>2019-01-11T20:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Track value of same variable across multiple data steps</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/526499#M143392</link>
      <description>&lt;P&gt;Great.&lt;/P&gt;
&lt;P&gt;Hopefully you found the issue with your INFILE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the default display of dates by the ls command of Unix will display just the date for files that are over 6 months old.&amp;nbsp; But the full datetime stamp is stored and newer versions of the ls command will allow you display the full date time value.&amp;nbsp; Try this that works on RedHat Linux to get the value in the format that the SAS informat DATETIME can read.&lt;/P&gt;
&lt;PRE&gt;/bin/ls -Al --time-style=+'%d%b%Y:%H:%M:%S'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 21:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Track-value-of-same-variable-across-multiple-data-steps/m-p/526499#M143392</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-11T21:06:35Z</dc:date>
    </item>
  </channel>
</rss>

