<?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: want to make few variables blank if the condition satisfies in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455569#M115259</link>
    <description>&lt;P&gt;I think your going at it the wrong way round.&amp;nbsp; Some steps:&lt;/P&gt;
&lt;P&gt;Step one, extract baseline record for each by group into a separate dataset.&lt;/P&gt;
&lt;P&gt;2 - merge this baseline record back to main data on by group&lt;/P&gt;
&lt;P&gt;3 - if value and baseline value both non-missing calculate chg as value - baseline value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 12:35:20 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-04-19T12:35:20Z</dc:date>
    <item>
      <title>want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455563#M115253</link>
      <description>&lt;P&gt;I have a question. in the attached data i need to make chg and pchg blank if aval is missing for visitnum 1. i.e if it is same studyid and same param then if first visit is missing i need to have chg and pchg as blank for the rest of the records. any help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=inc;  by studyid usubjid aval visitnum; run;
data kd;
   set inc;
   by studyid usubjid aval visitnum;
   retain chg pchg;
     
   if first.aval and aval=.  then 
      CHG=.;
	  PCHG=.;
	if last.aval then output;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455563#M115253</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-04-19T12:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455564#M115254</link>
      <description>&lt;P&gt;What is the problem when you run this code? Don't make us do work to find the problem, when you already know what the problem is.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455564#M115254</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-19T12:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455566#M115256</link>
      <description>&lt;P&gt;Please supply example data that is actually used in your code, or adapt the code to the example data posted.&lt;/P&gt;
&lt;P&gt;They don't match in dataset name and structure.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a question. in the attached data i need to make chg and pchg blank if aval is missing for visitnum 1. i.e if it is same studyid and same param then if first visit is missing i need to have chg and pchg as blank for the rest of the records. any help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=inc;  by studyid usubjid aval visitnum; run;
data kd;
   set inc;
   by studyid usubjid aval visitnum;
   retain chg pchg;
     
   if first.aval and aval=.  then 
      CHG=.;
	  PCHG=.;
	if last.aval then output;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.MYDATA;
  infile datalines dsd truncover;
  input F1:$6. F2:32. F3:$6. F4:$5. F5:$24. F6:$5. F7:32. F8:DATE9.;
datalines4;
usubj,,day,value,visit,study,visitnum,
HED101,0,Day 0,20.2,Visit 1 (Screening),NN11,1,30NOV2017
HED101,28,Day 28,20.2,Visit 6 (End of Week 4),NN11,34,12JAN2018
HED101,,,20.2,,NN11,34,
HED101,56,Day 56,20.2,Visit 10 (End of Week 8),NN11,61,07FEB2018
HED101,84,Day 84,20.2,Visit 1 (timeH),NN11,1,06MAR2018
HED101,84,Day 84,20.2,Visit 12 (measure),NN11,76,07MAR2018
HED101,,,20.2,,NN11,76,
HED101,0,Day 0,20.2,Visit 6 (End of Week 4),NN11,34,12JAN2018
HED101,28,Day 28,20.2,Visit 10 (End of Week 8),NN11,61,07FEB2018
HED101,56,Day 56,20.2,Visit 1 (timeH),NN11,1,06MAR2018
HED101,56,Day 56,20.2,Visit 12 (measure),NN11,76,07MAR2018
HED101,,,20.2,,NN11,76,
HED101,0,Day 0,20,Visit 1 (timeH),NN12,,
;;;;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455566#M115256</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-19T12:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455569#M115259</link>
      <description>&lt;P&gt;I think your going at it the wrong way round.&amp;nbsp; Some steps:&lt;/P&gt;
&lt;P&gt;Step one, extract baseline record for each by group into a separate dataset.&lt;/P&gt;
&lt;P&gt;2 - merge this baseline record back to main data on by group&lt;/P&gt;
&lt;P&gt;3 - if value and baseline value both non-missing calculate chg as value - baseline value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455569#M115259</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-19T12:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455572#M115261</link>
      <description>&lt;P&gt;I only have this dataset which has values for chg already and now i want to remove it. I do not have previous code for it&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455572#M115261</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-04-19T12:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455585#M115268</link>
      <description>&lt;P&gt;Please provide the appropriate data your have. Seems like the code you shared is generated by import wizard, in datalines you have your variables names. If your using the import wizard to created the sample data then check the option "First row contains variable name"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check this how to create a sample data&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 12:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455585#M115268</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-19T12:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455590#M115271</link>
      <description>&lt;PRE&gt;data WORK.MYDATA;
  infile datalines dsd truncover;
  input usubjid:$16. studyid:$3. paramcd:$4. aval:$3. ablf:$1. base:$3. chg:$3. pchg:$2. visit:$9. visitnum:32.;
datalines4;
AA1-US1103-S3317,AA1,URIN,.,,.,.,.,Visit 1,1
AA1-US1103-S3317,AA1,URIN,3.6,,.,.,.,,
AA1-US1103-S3317,AA1,URIN,3.6,,.,.,.,Visit 6,6
AA1-US1103-S3317,AA1,URIN,3.6,Y,3.6,0,0,Visit 6,6
AA1-US1103-S3317,AA1,URIN,4.2,,3.6,.,.,Visit 10,10
AA1-US1103-S3317,AA1,URIN,4.2,,3.6,0.6,17,Visit 10,10
AA1-US1103-S3317,AA1,URIN,5.6,,.,.,.,,
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,2,56,,
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,.,.,Visit 12,12
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,2,56,Visit 12,12
;;;;

proc sort data=WORK.MYDATA;  by studyid usubjid aval visitnum; run;
data kd;
   set WORK.MYDATA;
   by studyid usubjid aval visitnum;
   retain chg pchg;
     
   if first.aval and aval=.  then 
      CHG=.;
	  PCHG=.;
	if last.aval then output;
run;&lt;/PRE&gt;
&lt;P&gt;this is my data and code and i have more studyid and usubjid and param and want to make sure if the visitnumis 1 and aval is missing then chg and pchg should be blank.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 13:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455590#M115271</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-04-19T13:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455594#M115274</link>
      <description>&lt;P&gt;You have CHG and PCHG as characters and your giving "." (This will not be missing for character). Give them blank value instead.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 13:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455594#M115274</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-19T13:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455595#M115275</link>
      <description>&lt;P&gt;Errm, why is aval, base chg pchg all character?&amp;nbsp; Why is there a couple of rows with missing visit information?&lt;/P&gt;
&lt;P&gt;The data you present looks correct in terms of change from baseline, ablf is marked Y and base value is present from there on, as is change, which is as you would expect.&amp;nbsp; Its not relevant if visit 1 has no data, as there is a baseline.&amp;nbsp; If you remove this then you need to blank all the data items, ablf, base, chg, pchg.&amp;nbsp; E.g.&lt;/P&gt;
&lt;PRE&gt;data want (drop=blank);
  set have;
  by usubjid;
  if first.usubjid and aval="" then blank="Y";
  else if blank="Y" then do;
    ablf="";
    base="";
    chg="":
    pchg="";
  end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 13:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455595#M115275</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-19T13:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455604#M115279</link>
      <description>&lt;P&gt;There are many questions ... are all these variables really character?&amp;nbsp; Can VISIT really have a missing value on some observations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to use the data the way you presented it.&amp;nbsp; You may need to change some statements if your data really is different (such as if CHG is actually a numeric variable):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by usubjid studyid paramcd;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.paramcd);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by usubjid studyid paramcd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if visit=1 and aval=&lt;FONT color="#ff0000"&gt;.&lt;/FONT&gt; then remove_flag=1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.paramcd);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by usubjid studyid paramcd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if remove_flag=1 then do;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(chg);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call missing(pchg);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop remove_flag;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;******************* EDITED:&amp;nbsp; allowing that some variables might be numeric instead of character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AVAL should be numeric.&amp;nbsp; The code would work regardless of whether CHG and PCHG are character or numeric.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 15:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455604#M115279</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-19T15:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: want to make few variables blank if the condition satisfies</title>
      <link>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455630#M115292</link>
      <description>&lt;P&gt;Thew values are numeric and as the dataset is in excel when i imported it became character, but somehow it is not working.&lt;/P&gt;
&lt;P&gt;attaching new data. ignore the values as it is test data but if visitnum is 1 with same studyid,usubjid,paramcd&amp;nbsp; and aval is missing then the rest of the records for same s&lt;SPAN&gt;tudyid,usubjid,paramcd&amp;nbsp;&amp;nbsp;chg and pchg should be missing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;data WORK.MYDATA;
  infile datalines dsd truncover;
  input usubjid:$16. studyid:$3. paramcd:$5. aval:3. ablf:$1. base:3. chg:3. pchg:2. visit:$9. visitnum:32.;
datalines4;
AA1-US1103-S3317,AA1,URIN,.,,,.,.,Visit 1,1,,
AA1-US1103-S3317,AA1,URIN,3.6,,.,.,.,,,,
AA1-US1103-S3317,AA1,URIN,3.6,,.,.,.,Visit 6,6,,
AA1-US1103-S3317,AA1,URIN,3.6,Y,3.6,0,0,Visit 6,6,,
AA1-US1103-S3317,AA1,URIN,4.2,,3.6,.,.,Visit 10,10,,
AA1-US1103-S3317,AA1,URIN,4.2,,3.6,0.6,17,Visit 10,10,,
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,2,56,,,,
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,.,.,Visit 12,12,,
AA1-US1103-S3317,AA1,URIN,5.6,,3.6,2,56,Visit 12,12,,
AA1-US1103-S2317,AA1,PLASM,39,Y,42,-3,-7,Visit 1,1,,
AA1-US1103-S2317,AA1,PLASM,42,,42,0,0,,,,
AA1-US1103-S2317,AA1,PLASM,42,,39,3,8,Visit 5,5,,
AA1-US1103-S2317,AA1,PLASM,42,,42,.,.,Visit 6,6,,
AA1-US1103-S2317,AA1,PLASM,39,,42,-3,-7,Visit 10,10,,
AA1-US1103-S2317,AA1,PLASM,39,,39,0,0,Visit 10,10,,
AA1-US1103-S2317,AA1,PLASM,40,,42,-2,-5,,,,
AA1-US1103-S2317,AA1,URIN,40,,40,0,3,Visit 1,1,,
AA1-US1103-S2317,AA1,URIN,42,,40,0,0,Visit 12,12,,
AA1-US1103-S2317,AA1,URIN,42,,40,-2,8,Visit 12,12,,
;;;;
&lt;/PRE&gt;
&lt;P&gt;Sorry for the trouble but somehow it is mystery why it is not working.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 15:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/want-to-make-few-variables-blank-if-the-condition-satisfies/m-p/455630#M115292</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2018-04-19T15:02:46Z</dc:date>
    </item>
  </channel>
</rss>

