<?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: creation of new records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513486#M138356</link>
    <description>1. Separate letter of visit out. &lt;BR /&gt;2. Add that as a BY variable in addition your ID (assumed). &lt;BR /&gt;3. add a flag variable that sets to 1 if any value is greater than 40. &lt;BR /&gt;4. If last.ID then you can use an explicit output. &lt;BR /&gt;output;&lt;BR /&gt;if last.id then do;&lt;BR /&gt;*check if flag is gerater than one here and assign desired values;&lt;BR /&gt;visit = 'd-al'; c1=;c2=; mc1=;mc2=;&lt;BR /&gt;output;&lt;BR /&gt;visit = 'P-al'; c1=;c2=; mc1=;mc2=;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 15 Nov 2018 17:47:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-11-15T17:47:52Z</dc:date>
    <item>
      <title>creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513456#M138345</link>
      <description>&lt;P&gt;Hi , this is how my data is&lt;/P&gt;&lt;P&gt;subject&amp;nbsp; &amp;nbsp;visit&amp;nbsp; result&amp;nbsp; &amp;nbsp;tst&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d1&amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d2&amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d3&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d4&amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P1&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P2&amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P3&amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P4&amp;nbsp; &amp;nbsp; 70&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&lt;/P&gt;&lt;P&gt;I want to create two new records and 4 new vars c1 ,c2, mc1, mc2&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d-al&amp;nbsp; &amp;nbsp; ---&amp;nbsp; &amp;nbsp; &amp;nbsp; ------&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p-al&amp;nbsp; &amp;nbsp; -----&amp;nbsp; &amp;nbsp;-------&lt;/P&gt;&lt;P&gt;c1-- should be yes if result of all&amp;nbsp;same letter&amp;nbsp;visits are less than 40 ; mc1--should be yes if result of all same letter visits is missing&lt;/P&gt;&lt;P&gt;c2-should be yes if result of any&amp;nbsp;same letter visits is less than 40 : mc2--should be yes if result of any same letter visits is missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;record d-al sholud be based on all d visits&lt;/P&gt;&lt;P&gt;recod p-al should be based on all p visits&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513456#M138345</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T17:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513461#M138346</link>
      <description>Post the exact output you want.</description>
      <pubDate>Thu, 15 Nov 2018 17:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513461#M138346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T17:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513466#M138347</link>
      <description>&lt;P&gt;So your desired output data set has only two rows, correct?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513466#M138347</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-15T17:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513469#M138348</link>
      <description>&lt;P&gt;subject&amp;nbsp; &amp;nbsp;visit&amp;nbsp; result&amp;nbsp; &amp;nbsp;tst&amp;nbsp; &amp;nbsp; &amp;nbsp;c1&amp;nbsp; &amp;nbsp; &amp;nbsp;c2&amp;nbsp; &amp;nbsp; mc1&amp;nbsp; mc2&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d1&amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&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; -&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d2&amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&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;-&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d3&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d4&amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P1&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P2&amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P3&amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P4&amp;nbsp; &amp;nbsp; 70&amp;nbsp; &amp;nbsp; &amp;nbsp; EST&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&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;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;d-a&amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Z&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p-a&amp;nbsp; &amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Z&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513469#M138348</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T17:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513472#M138349</link>
      <description>&lt;P&gt;Do you want this do be a SAS data set? It is rarely a good idea to have summary rows in data sets. They belong in reports.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513472#M138349</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-11-15T17:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513473#M138350</link>
      <description>&lt;P&gt;Yes i want it in a dataset&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513473#M138350</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T17:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513475#M138351</link>
      <description>Will you have multiple ID or just a single as in your example? The better representative the sample is of your true data the more likely you are to get an answer that actually works for you.</description>
      <pubDate>Thu, 15 Nov 2018 17:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513475#M138351</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T17:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513476#M138352</link>
      <description>&lt;P&gt;yes i do have multiple id,i just quoted a piece of data as i cant represent all data here.Assume that there are multiple subjects and multiplle tst values like EST and PGT and TGT .&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513476#M138352</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T17:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513486#M138356</link>
      <description>1. Separate letter of visit out. &lt;BR /&gt;2. Add that as a BY variable in addition your ID (assumed). &lt;BR /&gt;3. add a flag variable that sets to 1 if any value is greater than 40. &lt;BR /&gt;4. If last.ID then you can use an explicit output. &lt;BR /&gt;output;&lt;BR /&gt;if last.id then do;&lt;BR /&gt;*check if flag is gerater than one here and assign desired values;&lt;BR /&gt;visit = 'd-al'; c1=;c2=; mc1=;mc2=;&lt;BR /&gt;output;&lt;BR /&gt;visit = 'P-al'; c1=;c2=; mc1=;mc2=;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513486#M138356</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T17:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513490#M138358</link>
      <description>&lt;P&gt;i couldnt understand your logic&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513490#M138358</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T17:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513492#M138360</link>
      <description>Which step?</description>
      <pubDate>Thu, 15 Nov 2018 17:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513492#M138360</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T17:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513500#M138362</link>
      <description>&lt;P&gt;I have attached a text file and out should contain&amp;nbsp; ftwo more records for every subject,&lt;/P&gt;&lt;P&gt;with visit as d-AA p-AA&lt;/P&gt;&lt;P&gt;for d-aa row c1,c2,mc1,mc2 shoudl be populateda s&lt;/P&gt;&lt;P&gt;c1 should be Y if any of result value of all dvisits&amp;nbsp; is less than 40&lt;/P&gt;&lt;P&gt;c2- should be Y if all result value of dvisits are greater than 40&lt;/P&gt;&lt;P&gt;mc1-if any of result is missing for d visits then mc1 should be Y&lt;/P&gt;&lt;P&gt;mc2-if all results are missing for d visits then mc2 should be Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same for p -aa row also&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for paa row c1,c2,mc1,mc2 shoudl be populateda s&lt;/P&gt;&lt;P&gt;c1 should be Y if any of result value of all ovisits&amp;nbsp; is less than 40&lt;/P&gt;&lt;P&gt;c2- should be Y if all result value of pvisits are greater than 40&lt;/P&gt;&lt;P&gt;mc1-if any of result is missing for pvisits then mc1 should be Y&lt;/P&gt;&lt;P&gt;mc2-if all results are missing for pvisits then mc2 should be Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so output should contain 2 records more per subject&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513500#M138362</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-11-15T18:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: creation of new records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513516#M138364</link>
      <description>&lt;P&gt;Flag the result values into 3 categories, Y-less than 40 , N - greater than 40 and M missing values and then later read all the values for the group and searching the combined string would answer your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input subject visit:$3. result tst:$3.;
datalines;
101 d1 20 EST
101 d2 30 EST
101 d3 40 EST
101 d4 50 EST
101 P1 40 EST
101 P2 50 EST
101 P3 60 EST
101 P4 70 EST
;
run;
proc format ;
value flag low-&amp;lt;40='Y'
			   .='M'
			   other='N';
run;


data want_grp;
set have;
visit_grp=substr(visit,1,1);
result_Flag=put(result,flag.);
run;


proc sort data=want_grp;
by subject visit_grp;
data want;
format result_Flag_cat $15.;
do until (last.visit_grp);
set want_grp;
by subject visit_grp;
result_Flag_cat=cats(result_Flag_cat,result_Flag); /* All values in last record */
end;
/* If Y exists then atleast one values has less than 40 */
if find(result_Flag_cat,'Y')&amp;gt;0 then c1='Y' ; else c1='N';
/* If no Y or M then all values are greater than 40 */
if find(result_Flag_cat,'Y')=0 and find(result_Flag_cat,'M')=0    then c2='Y' ; else c2='N';
/* If atleast one values is missing */
if  find(result_Flag_cat,'M')&amp;gt;0 then mc1='Y'; else mc1='N';
/* If all results are missing, i.e. no Y or N */
if find(result_Flag_cat,'M')&amp;gt;0 and find(result_Flag_cat,'Y')=0 and find(result_Flag_cat,'N')=0  then mc2='Y'  ; else mc2='N';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creation-of-new-records/m-p/513516#M138364</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-11-15T18:43:13Z</dc:date>
    </item>
  </channel>
</rss>

