User:Mfoxwell

From PHUSE Wiki
Jump to: navigation, search
  • Mark Foxwell*
#
<table align=center style="background: ivory;color:maroon;font-style:italic;font-family:arial;font-weight:bold;font-size:10pt;"> 
#
<tr><th> Heading 1 </th><th> Heading 2 </th></tr>
#
<tr>
#
<td style="padding:10px;"> This is cell 1 text </td>
#
<td style="padding:10px;"> This is cell 2 text </td>
#
</tr>
#
</table>

The majority of the time the numeric formats provided in SAS are enough to deal with datetime values. However, there may be times when the formats provided do not meet our needs. Recently I've been asked to write out a SAS data set into a flat file and for a datetime variable the condition was to be written in the form of dd-mm-yyyy hh:mm:ss. The standard datetime format provided did not meet the requirement so in order to create the new format type I used the code below:

proc format;
  picture MyMSdt other='%0d-%0m-%0Y %0H:%0M:%0S' (datatype=datetime);
run;

data test;
  mydatetime='25nov2009 14:44:56'dt;
  format newdt MyMSdt.;
  newdt=mydatetime;
  put mydatetime= newdt=;
run;
proc format;
  picture MyMSdt other='%0d-%0m-%0Y %0H:%0M:%0S' (datatype=datetime);
run;

data test;
  mydatetime='25nov2009 14:44:56'dt;
  format newdt MyMSdt.;
  newdt=mydatetime;
  put mydatetime= newdt=;
run;
proc sql;
create table test as 
select *, g.tt 
from frame f left join gframe g 
on f.id= g.id 
;
quit;


• Hard coding is strongly discouraged – coding should be data driven. If hard coding is unavoidable then this should be clearly documented e.g. using comments and PUT statements to the log to show what has been hard coded Example of hard coding

if subjid = '2345' and visitnum = 1 and vstestcd='HRATE' then do; 
  put 'Before hard coded change ' subjid= visitnum= vstestcd= vsorres=;
  vsorres = 100;
  put 'After hard coded change ' subjid= visitnum= vstestcd= vsorres=;
end;


• Hard coding is strongly discouraged – coding should be data driven. If hard coding is unavoidable then this should be clearly documented e.g. using comments and PUT statements to the log to show what has been hard coded Example of hard coding

* As per findings of review - this record has incorrect value. Per PI, change value to 100. Code updated by Xxx Xxx ;
if usubjid = '2345' and visitnum = 1 and vstestcd='HRATE' then do; 
  put 'Before hard coded change ' usubjid= visitnum= vstestcd= vsorres=;
  vsorres = 100;
  put 'After hard coded change ' usubjid= visitnum= vstestcd= vsorres=;
end;

The LOG shows: mydatetime=1574779496 newdt=25-11-2009 14:44:56

See also Tips:Pound sign using picture format Template:ExternalReadMore
Template:SubmittedBy


MFoxwell Notes


  • Contributing to the Phuse Wiki

There is lots of guidance on the wiki about how to add and edit new pages, but it can sometimes become a bit overwhelming on your first attempt. This short guide describes the first things that you need to know with an emphasis on features that are enabled and will be of use for the PhUSE wiki in particular.

  • Adding a new page

There are several ways to add a new page, and the following 4 are likely to be used on the PhUSE wiki. The approach depends on whether you want to create a page from scratch or want to use an exisiting template. There are several of these available particulalry for those working in the FDA groups.

  • Creating a new page from scratch
  1. Use the "create a new page box" on the home page: Type the name of your new page in the box and you will be prompted for more information.
  2. Search for a non existent page: Type the name of your new page in the search box top right. You will then be prompted to create the new page if you want to do this.
  3. Create a link from another page: When editing an existing page, create a link to a non existent page, save the edits and and click on the link.
  4. Template generator: Some pages such as meeting teplates for the FDA working groups can be generated by template. Type the file name in the create minutes box and click the button. This creates the new page with appropriate headings but you will still need to add a link to this page from the main working group page- using the normal editing process.

In all 3 cases, you will get a screen that prompts you to start editing and create the new page.