<?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: Uniform values of numeric and character variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988423#M43901</link>
    <description>&lt;P&gt;Base on your data, another working solution is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data DB;
  input ID :$200. Event :$200. Date :date09.;
    format Date date9.;
cards;
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 .        01SEP2024
0001 Event1      .
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 .        08DEC2025
0002 Measure      .
;

proc sql;
create table want(drop=_Event _Date) as
select *,max(_Event) as Event,max(_Date) as Date format=date9.
 from DB(rename=(Event=_Event Date=_Date))
  group by ID;
quit;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 May 2026 07:42:44 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-05-21T07:42:44Z</dc:date>
    <item>
      <title>Uniform values of numeric and character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988206#M43884</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following dataset:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$200. Event :$200. Date :date09.;
    format Date date9.;
cards;
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 .        01SEP2024
0001 Event1      .
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 .        08DEC2025
0002 Measure      .
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For some reasons There are missing values. Is there a way to uniform values by ID?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB1;
  input ID :$200. Event :$200. Date :date09.;
    format Date date9.;
cards;
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 Measure  08DEC2025
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The two variables are not related and missing values come from previous computations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally there are no multiple variable values for each ID.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2026 13:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988206#M43884</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2026-05-18T13:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Uniform values of numeric and character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988207#M43885</link>
      <description>&lt;P&gt;Use RETAIN statement.&lt;/P&gt;
&lt;P&gt;(does not work if missing values occur in the starting rows for an ID)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$200. Event :$200. Date :date09.;
    format Date date9.;
cards;
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 .        01SEP2024
0001 Event1      .
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 .        08DEC2025
0002 Measure      .
run;

data DB_want;
 LENGTH Event_retain $ 200 Date_retain 8;
 set DB;
 retain Event_retain Date_retain;
 by ID;
 if first.ID then do; Event_retain=''; Date_retain=.; end;
 if Event NE '' then Event_retain = Event;
 if Date  NE .  then Date_retain  = Date;
 if Event EQ '' then Event = Event_retain;
 if Date  EQ .  then Date  = Date_retain;
 DROP   Event_retain Date_retain; 
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2026 13:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988207#M43885</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2026-05-18T13:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Uniform values of numeric and character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988208#M43886</link>
      <description>&lt;P&gt;If you are asking the missing values be replaced by the previous value from the same ID then you can use the UPDATE statement to handle this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The UPDATE statement is intended to apply transactions to the current data, so missing values leave the current value unchanged.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But by using an empty version of the dataset as the base dataset and using all of the values as transactions you can implement Last Observation Carried Forward.&amp;nbsp; Just add an OUTPUT statement to force the data step to write all of the observations instead of just the last per BY group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   update have(obs=0) have;
   by id;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there are other variables you did not want to have the missing values replaced then you can read them in again by adding a SET statement using the KEEP= (or DROP=) dataset option.&amp;nbsp; For example if you only want the EVENT and DATE variables to have the LOCF applied then you could do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   update have(obs=0) have;
   by id;
   set have(drop=event date);
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2026 13:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988208#M43886</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-05-18T13:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Uniform values of numeric and character variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988423#M43901</link>
      <description>&lt;P&gt;Base on your data, another working solution is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data DB;
  input ID :$200. Event :$200. Date :date09.;
    format Date date9.;
cards;
0001 Event1   01SEP2024
0001 Event1   01SEP2024
0001 .        01SEP2024
0001 Event1      .
0002 Measure  08DEC2025
0002 Measure  08DEC2025
0002 .        08DEC2025
0002 Measure      .
;

proc sql;
create table want(drop=_Event _Date) as
select *,max(_Event) as Event,max(_Date) as Date format=date9.
 from DB(rename=(Event=_Event Date=_Date))
  group by ID;
quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2026 07:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Uniform-values-of-numeric-and-character-variables/m-p/988423#M43901</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-05-21T07:42:44Z</dc:date>
    </item>
  </channel>
</rss>

