Copyright © 2009, SAS Institute Inc. All rights reserved. Neat Code from Rick Rick Langston, SAS Institute Inc.

Slides:



Advertisements
Similar presentations
To print your results, click on the printer icon. Choose from the printing options suggested. You can choose to remove items from folder after printing.
Advertisements

PubMed/History; Accessing Full-Text Articles (module 4.4)
EndNote Web Reference Management Software (module 5.1)
EndNote Web Reference Management Software (module 5)
The results for this search are displayed in the Summary format with a total of 3808 citations.
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the: course is a PowerPoint demonstration intended to introduce.
Extended DISC Online System User Instruction: How to Generate Reports
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the:  course is a PowerPoint demonstration intended to introduce.
Empowering the Education Community to Improve Student Performance through the Intelligent Use of Practical Data EdGate Training: Part 3 - SchoolNotes.
A “LOTTO” SAS for you! or, “Check Your Balls with SAS Arrays” By Keith McWhorter Georgia Technology Authority January 30, 2007.
EndNote. What is EndNote:  EndNote is referencing software that enables you to create a database of references from your readings. Your database of references.
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Student Manager Catalog Builder An ACEware Webinar.
Start My Easter Bingo Start My Easter Bingo Start My Easter Bingo Start My Easter Bingo Setup ©2015 Headstart Languages Limited. All rights reserved.
Using KompoZer -- a web editor A collection of video tutorials
Calculating driving distance between two places
FILE UPLOADS CHAPTER 11. THE BASIC PROCESS 1.The HTML form displays the control to locate and upload a file 2.Upon form submission, the server first stores.
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
Copyright 2003 By NTREIS, Inc. Welcome to NTREIS Listings “ADD/EDIT” PowerPoint Presentation.
The following slide presentation is aimed at students who are new to the IIA’s distance learning programme and who need to familiarise themselves with.
Creating a Web Page HTML, FrontPage, Word, Composer.
Designing a Classroom Web Site Using NVU Beginning Level.
PubMed/History; Accessing Full-Text Articles (module 4.4)
Web of Science. Copyright 2006 Thomson Corporation 2 Example: (bird* or avian) and (flu or influenz*) Enter your terms to be searched. Search fields are.
CIITS Institute: Creating District Curriculum & Materials Copyright © 2012 Schoolnet, Inc. All rights reserved.
Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent Contractor, London, UK Stacking Rich Text Format (RTF) - %SRiT Duong Tran – Independent.
The Online Submission Process: Guidelines and Training for Authors Marlowe H. Smaby, Michael R. Smith, Cleborne D. Maddux.
Go to the Roseville City School District Website and pull down the Employees menu. Then click Online Services. Scroll down until you see Global Scholar-
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 7: Web Forms © 2007 Prosoft Learning Corporation All rights reserved ITD 110 Web Page Design.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Intro to Google Docs Table of Contents Video What is Google Docs? What can you do with it? Creating a new document Uploading an existing document.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 HTML Forms
For more information, call (610) AcademyOne, Inc. All Rights Reserved. © How to use the SOAR Transfer Center on your website Created.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 12: Advanced File Operations.
How to Post my Response. Click! To reply or respond to an existing topic/question, start by reading the message in the topic. Reply from within each.
1 HTML Forms
EndNote. What is EndNote? EndNote is referencing software that enables you to create a database of references from your readings.
Macro Variable Resolution Enio Presutto York University, Toronto, Canada.
12 steps for Mail Merge Setup Mpact Magic. Step 1 Open Your MS Outlook program and put it an offline mode. Go to Main Menu >> File >> Work Offline.
1 EndNote X2 Your Bibliographic Management Tool 29 September 2009 Humanities and Social Sciences Resource Teams.
How long is the quiz available? The quiz will always have a start time but the end time can be unlimited or fixed. If your quiz has an END time, you will.
Student Quick Start Guide Prepared by: Information Services Division Perpustakaan Sultan Abdul Samad Universiti Putra Malaysia
We now will look at options for saving searches in CINAHL. We have accessed the Results for Chloroquine AND Pyrimethamine AND Sulfadoxine search. We now.
Microsoft ® Outlook 2000 Integrating Outlook with Office Applications.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
File Management 1.Keeping all your files in one location, such as “My Documents” is a very good idea. Have folders within your “My Documents” for different.
LOGIN PAGE Login Page Support CRM:
CC07 PhUSE 2011 Seven Sharp tips for Clinical Programmers David Garbutt Rohit Banga BIOP AG.
Publications Coordinators – Create and Verify a Publication.
V 0.1Slide 1  send – Send How to send in WebSAMS? Access Control Other Information Configuration Customization  manage.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
Fab25 User Training Cerium Labs LabCollector - LIMS Lynette Ballast.
How to make your paper resources available to the digital generation.
Using the Macro Facility to Create HTML, XML and RTF output Rick Langston, SAS Institute Inc.
Purchase Orders May 2015 Supply Chain Platform: Rolls-Royce Training for Controls and Data Services Limited.
Hints and Tips SAUSAG Q SORTING – NOUNIQUEKEY The NOUNIQUEKEY option on PROC SORT is a useful way in 9.3 to easily retain only those records with.
Introduction to EBSCOhost
and Network Management Presented by: Information Technology.
Intro to Google Docs 2014.
Reporting Audience: All Audiences
Adding a File to a Course
Outlook Recovery Freeware is the professional tool to open & read OST file without Outlook.
Oracle Sales Cloud Sales campaign
WEB PROGRAMMING JavaScript.
HTML Tables.
[Event Title Here] [Event Title Here] [Event Title Here]
Tutorial 8 Sharing, Integrating, and Analyzing Data
Purchase Document Management
Presentation transcript:

Copyright © 2009, SAS Institute Inc. All rights reserved. Neat Code from Rick Rick Langston, SAS Institute Inc.

Copyright © 2009, SAS Institute Inc. All rights reserved. SAS Examples to discuss Avoiding attachment problems Using Windows API calls easily Creating SAS data sets from HTML tables Informatting binary dates Getting combinations of letters

Copyright © 2009, SAS Institute Inc. All rights reserved. Avoiding attachment problems Need to send binary data? Especially need to send a zip file? So many mail servers reject those Send a text file using SAS!

Copyright © 2009, SAS Institute Inc. All rights reserved. Avoiding attachment problems: %let filename=traj.zip; *-----write out the initial DATA step code-----*; data _null_; file "sascode.txt"; put "data _null_; infile cards;"; put " file '&filename.' recfm=f lrecl=1;"; put " put " l=length(record);"; put " record:$hex72.;"; put " l2=l/2; record $varying36. l2;"; put " cards;"; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Avoiding attachment problems *-----write out the contents of the file in hex, 72 hex digits at a time-----*; data _null_; infile "&filename." recfm=f lrecl=36 length=l; file "sascode.txt" mod; input; length hex $72; hex=putc(_infile_,'$hex',l*2); put hex; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Avoiding attachment problems *-----wrap up with a run-----; data _null_; file "sascode.txt" mod; put 'run;'; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Avoiding attachment problems data _null_; infile cards; file 'traj.zip' recfm=f lrecl=1; record:$char72.; l=length(record); record:$hex72.; l2=l/2; record $varying36. l2; cards; 504B BFC38EEDAEEA7A AD D F F 61646A D756C C E E48B18EEF4D C595DB6EDA401086AF E28CCD456F8891E B FD100000D6FF0B run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Using Windows API calls easily filename sascbtbl temp; data _null_; file sascbtbl; input; put _infile_;cards4; routine MessageBoxA minarg=4 maxarg=4 returns=long module=user32 stackpop=called; arg 1 num input format=pib4. byvalue; arg 2 char input format=$cstr200.; arg 3 char input format=$cstr200.; arg 4 num input format=pib4. byvalue; ;;;;

Copyright © 2009, SAS Institute Inc. All rights reserved. Using Windows API calls easily data _null_; button = modulen('MessageBoxA',0, 'Instructions: Click OK for X, Otherwise Click Cancel', 'Sample MessageBox Title', 1); if button=1 then do; put 'OK was clicked'; end; if button=2 then do; put 'Cancel was clicked'; end; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Using Windows API calls easily

Copyright © 2009, SAS Institute Inc. All rights reserved. Using Windows API calls easily Paper on this subject: Richard Devenezias information:

Copyright © 2009, SAS Institute Inc. All rights reserved. Creating SAS data sets from HTML tables My paper from SAS Global Forum 2009: %readhtml macro defined and discussed Only a few techniques highlighted here

Copyright © 2009, SAS Institute Inc. All rights reserved.

Creating SAS data sets from HTML tables /* This step makes a local copy of the URL contents into a temporary file. This makes random access of the file simpler, and also gives us an opportunity to find the total size of the file to use that value in a subsequent LRECL= option. Also, we can upcase all the tags (anything between ) so that we can accept any casing combination. */ filename myfile temp; data _null_; infile urltext recfm=f lrecl=1 end=eof; file myfile recfm=f lrecl=1; retain upcase 0; x $char1.; if x='<' then upcase=1; else if upcase and (x=' ' or x='>') then upcase=0; if upcase then x=upcase(x); x $char1.; if eof; call symputx('filesize',_n_); run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Creating SAS data sets from HTML tables /* This step makes a local copy of the URL contents into a temporary file. This makes random access of the file simpler, and also gives us an opportunity to find the total size of the file to use that value in a subsequent LRECL= option. Also, we can upcase all the tags (anything between ) so that we can accept any casing combination. */ filename myfile temp; data _null_; infile urltext recfm=f lrecl=1 end=eof; file myfile recfm=f lrecl=1; retain upcase 0; x $char1.; if x='<' then upcase=1; else if upcase and (x=' ' or x='>') then upcase=0; if upcase then x=upcase(x); x $char1.; if eof; call symputx('filesize',_n_); run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Creating SAS data sets from HTML tables data detail(keep=text col); infile myfile recfm=f lrecl=&filesize. column=c missover; array which{3} $8 _temporary_ ('TABLE','TR','TD'); length tag $8; do i=1 to 3; tag='<'||which{i}; link readfile; tag='</'||which{i}; link readfile; end; return; readfile:; obscount=0; do if c>&filesize then leave; col=c; obscount+1; output; end; return;

Copyright © 2009, SAS Institute Inc. All rights reserved. Informatting binary dates data temp; fmtname='PDYMD'; type='I'; do label='01jan1990'd to '31dec2010'd; y=year(label)-1900; m=month(label); d=day(label); string=put(y,z3.)||put(m,z2.)||put(d,z2.)||'F'; start=input(string,$hex8.); output; end; keep fmtname type start label; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Informatting binary dates 27 data _null_; set temp(obs=5); 28 put fmtname= type= label= label=date9. start=$hex8.; 29 run; fmtname=PDYMD type=I label=10958 label=01JAN1990 start= F fmtname=PDYMD type=I label=10959 label=02JAN1990 start= F fmtname=PDYMD type=I label=10960 label=03JAN1990 start= F fmtname=PDYMD type=I label=10961 label=04JAN1990 start= F fmtname=PDYMD type=I label=10962 label=05JAN1990 start= F

Copyright © 2009, SAS Institute Inc. All rights reserved. Informatting binary dates proc format cntlin=temp; data _null_; x=input(' f'x,pdymd4.); put x=date9. +1 '(should be 01JAN1990)'; x=input(' f'x,pdymd4.); put x=date9. +1 '(should be 31DEC1999)'; x=input(' f'x,pdymd4.); put x=date9. +1 '(should be 01JAN2000)'; x=input(' f'x,pdymd4.); put x=date9. +1 '(should be 31DEC2010)'; run; x=01JAN1990 (should be 01JAN1990) x=31DEC1999 (should be 31DEC1999) x=01JAN2000 (should be 01JAN2000) x=31DEC2010 (should be 31DEC2010)

Copyright © 2009, SAS Institute Inc. All rights reserved. Getting combinations of letters data temp; do a=1 to 6; do b=1 to 6; do c=1 to 6; do d=1 to 6; do e=1 to 6; do f=1 to 6; if 2**a+2**b+2**c+2**d+2**e+2**f=( ) then output; end; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Getting combinations of letters data _null_; set temp; value='festal'; comb=substr(value,a,1)|| substr(value,b,1)|| substr(value,c,1)|| substr(value,d,1)|| substr(value,e,1)|| substr(value,f,1); put comb=; run;

Copyright © 2009, SAS Institute Inc. All rights reserved. Getting combinations of letters data _null_; set temp; value='festal'; comb=substr(value,a,1)|| substr(value,b,1)|| substr(value,c,1)|| substr(value,d,1)|| substr(value,e,1)|| substr(value,f,1); put comb=; run;

Copyright © 2009, SAS Institute Inc. All rights reserved.