Most Recent Blogs
From sasCommunity
So, I was talking about pontification. Sometimes, I am asked: "what makes a good SAS Administrator?" There are many answers (just like writing SAS code!) but there are enough commonalities to elevate this question to one which can be answered by a "Things You Should Know" list.
Nine things you should know about SAS® administration1. SAS is not like Oracle, your email system, or anything else for that matter. When viewed as a system, SAS software does not behave like a database, or any other operational system. Usually, very little goes on without the direct involvement of users. In fact, it’s the users’ activity which defines how SAS behaves, and is also the direct value product of the system. Traditional pure-play IT management folks are not usually comfortable with systems which are made up of a set of infinitely flexible tools (like SAS is). For this reason alone, SAS deserves special treatment; it is an environment rather than a directed, deterministic system. 2. SAS guys are not like IT guys. Related to point #1 – those experts who are the community of SAS users in your organization are not at all like "programmers". Usually, programmers are driven by specifications and have a very clear picture of their desired product. This isn’t the case with much SAS work – SAS "programmers" often work in an exploratory, data-driven way – the exact nature of the end product is not clear, and technical considerations are secondary to the business problems they are trying to solve. 3. Yes, SAS users really do need all that data. Almost all SAS work is data-oriented. We often see cases where highly skilled quantitative people spend up to 80% of their time in data preparation, often because their IT support has not anticipated the needs of these people. Although it is an investment challenge in terms of development resources, possibly the single most valuable resource for many of the mathematicians we work with would be a well structured Analytic Data Mart. It’s a common scenario that there is no reuse of data integration code between analysts – each individual reinvents the wheel every time, whether or not one of their colleagues has already solved the problem. The SAS Administrator is well placed to lead the charge to provide the right data to the right people, filling a gap between the business (in this case, SAS users) and the IT organization. 4. All problems are your problem. With reference to #2 – as subject area experts, SAS users may not be able to articulate a technical symptom correctly. We often hear of cases where an expired database password has resulted in an obscure log message which in turn led to a multi-week triage effort involving SAS Technical Support, and ultimately a frustrated and non-productive SAS user. Be involved, and be available to help. 5. Sometimes the wood is obscured by the trees. Naturally, SAS tools do not exist in a vacuum. With reference to #1, SAS technologies are always used in support of one or more business processes. This implies that any change in the business process will impact the supporting SAS processes – business rules and logic, analyses, even data currency and granularity can shift without warning. Understand and monitor the business processes supported by SAS technologies. Understand the role SAS plays in the overall process. This allows both an insight into the details of the SAS artifacts which the community has developed, allowing you to more effectively triage problems and understand risks and impacts, and also puts the SAS Administrator in an excellent position to guide the SAS community through business changes. 6. Just because you have a hammer... Pick the "right" tool for the job. To give a very specific but illuminating example: don't bother writing a SAS/C module to decode DICOM image files. The breadth of what can be accomplished with SAS tools constantly amazes us (does anyone remember SAS/AF Blackjack?) This does not, however, mean that everything should be accomplished using SAS tools. Know that it is always possible, for example, to get complex data integration done at source (see #3), if that is technically and economically feasible. 7. All problems are communication problems. Be a steward rather than an administrator. If you do not have an internal user group, make one. Get SAS users to talk about what they do. You learn; they learn; they start reusing data and code. Best Practices are only a symptom of effective communication. 8. Everybody loves a geek. Subscribe to SAS technology news, attend conferences, and talk to your Account Executive regularly. SAS tools are continually revised and new ones invented - maybe one of these is your silver bullet? (see #5) 9. The world is not flat. SAS is always part of a wider technical ecosystem. Many problems arise because of the interfaces between these systems. So, as well as the SAS Administrator’s priority of understanding the business processes, there is also a responsibility to understand the wider technical landscape.
|
Williams, Roberts, Young Inc, Full time permanent position in Winston Salem, NC, Contact Eddie Perez at 336-777-1938 or 1-800-632-0360. Requirements: Undergraduate Degree (preferably a Masters) in Statistics. Description: One of the nations's largest property and casualty insurance companies has an immediate need for a Sr. Product Development Analyst. Conducts data mining, data analysis, mathematical and statistical modeling and business modeling. The analyst provides project management for analytic and development teams on analysis projects and software development projects. The analyst provides feasibility assessments, systems analysis, and functional specifications for analytic systems and business support for Product Development management. This position mentors less experienced personnel. -Performs data mining and data analysis to support Product Development management decision-making. -Develops mathematical, statistical and business models that enhance understanding of current business processes and identify new opportunities. -Provides analytic leadership and project management on major analysis and software development projects. -Provides feasibility assessments, systems analysis and functional specifications for analytic systems for Product Development management. -Coordinates the activities of other analysts in the design development and implementation of system specifications. -Reviews, evaluates, and recommends Product Development initiatives including vendor proposals. -Serves as an analytic consultant to Product Development management and other business units. -Provides business support through preparation and presentation of data to Product Development management. Qualifications: Qualifications Required: -Expert in SAS for Unix, PC and mainframe environments. -Proficient in data mining and data analysis. -Proficient in advanced statistical techniques used in Product Development including Regression, ANOVA, Min Bias, Generalized Linear Models and -Logistic Regression and experience in applying them to Product Development problems. -Expert analytical skills for determination of problem, examination of options, and deciding the most appropriate course of action. -Expert in use of software for data processing and manipulation to support analytics. -Proficient in the use of presentation software including MS Excel, MS Word, MS PowerPoint to generate system and end user statistical reports. -Proficient in project management methodologies. -Knowledge of the latest statistical and related software developments. -Demonstrated leadership ability/ supervisor experience. -At least a Bachelor's degree in a numerate discipline with a statistical component (Master's degree desired). Qualifications Desired: -Excellent communication and interpersonal skills. This includes the ability to provide clear explanations of problems and resolution conclusions -Promotes a team environment where information is readily shared. -Excellent customer service skills -Ability to train end-users and less experienced personnel. -Excellent written and oral communications skills, especially in preparing and presenting results and recommendations -Able to present technical concepts in non-technical user-friendly understandable language. Company is open to relocation.
|
This is my first entry here in the community and I'm trying to see how well I can adapt to this wiki stuff. I just registered an in-house user group with SAS so I'm going to try my luck at adding some information about it. Wish me luck; and forgive me if I butcher it. I had a great time at the SAS Global Forum here in San Antonio. I met a lot of new people and was able to connect friends I haven't seen in a while. I also was able to get a co-author to my first paper! Hopefully it will be accepted at some of the regional user group meetings and eventually at the next Global Forum in 2009.
|
VarMatch MacroHave you ever wanted to select variables based off of the leading or ending character(s)? When some set of leading character(s) is wanted the Colon comes in very handy. Data Need ; Set Have ( Keep = Var: ) ; <Some SAS Code> Run ; This Keeps all variables starting with 'Var'.
%Macro VarMatch( DSN = , Pattern = , PRX= ) ;
/****************************************************************************/
/** Macro Name : VarMatch **/
/** **/
/** **/
/** Purpose : Returns A List Of Variables From A Data Set That Matces A **/
/** Given Pattern. **/
/** **/
/** Parameters : DSN ~ Data Set To Get Variables From. It Can Be Either **/
/** Just A Member Name Which Cause The Macro To Look **/
/** In The Work Directory Or A Two Level Name. **/
/** **/
/** Pattern ~ Is A Simple Pattern Where The User Gives The **/
/** Known Letters in The Variables Name Seperate By **/
/** * For Those They Do Not. **/
/** Examples: ABC* = All Vars That Start With ABC **/
/** *ABC = All Vars That End With ABC **/
/** A*C = All Vars That Start With A And **/
/** End With C. **/
/** **/
/** PRX ~ Is A Perl Regular Expression. This Is Designed For **/
/** Advanced Users Who Fully Understand RegEx. **/
/** **/
/** Created By: Toby Dunn ***************** **/
/** Created On: 03/12/2008 * Make It Right * **/
/** ***************** **/
/****************************************************************************/
%Local DSID VarNum I VarName Pattern VarList Close ;
%If ( %Length(&DSN) EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put ERROR: The DSN Parameter Is Empty. ;
%Put ERROR: Please Specify A Valid Value. ;
%Put ;
%Put ;
%Return ;
%End ;
%If ( %SysFunc( Exist( &DSN ) ) EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put ERROR: The Data Set [&DSN] Does Not Exist!!! ;
%Put ERROR: Please Check The Value Of DSN= Parameter ;
%Put ;
%Put ;
%Return ;
%End ;
%If ( %Length( &Pattern ) EQ 0 ) And
( %Length( &PRX ) EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put ERROR: There Is No Pattern Or RegEx To Match. ;
%Put ERROR: Please Specify A Valid Value For Pattern Or PRX. ;
%Put ;
%Put ;
%Return ;
%End ;
%If ( %Length( &Pattern ) GT 0 ) And
( %Length( &PRX ) GT 0 ) %Then %Do ;
%Put ;
%Put ;
%Put NOTE: A Value Was Given For Both Pattern And PRX. ;
%Put NOTE: The PRX RegEx Will Be Used. ;
%Put ;
%Put ;
%End ;
%Let DSID = %Sysfunc( Open( &DSN , I ) ) ;
%If ( &DSID EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put ERROR: Data Set [&DSN] Could Not Be Opened. ;
%Put %SysFunc( SysMSG() ) ;
%Put ;
%Put ;
%End ;
%Let VarNum = %SysFunc( AttrN( &DSID , NVars ) ) ;
%If ( &VarNum EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put ERROR: Data Set [&DSN] Has No Variables. ;
%Put ;
%Put ;
%End ;
%If ( %Length( &PRX ) > 0 ) %Then %Do ;
%Let Pattern = %SysFunc( PRXParse( &PRX ) ) ;
%End ;
%Else %Do ;
%Let Pattern = %SysFunc( TranWrd( &Pattern , * , .* ) ) ;
%Let Pattern = %SysFunc( PRXParse( /^&Pattern$/i ) ) ;
%End ;
%Do I = 1 %To &VarNum ;
%Let VarName = %Sysfunc( VarName( &DSID , &I ) ) ;
%If ( %SysFunc( PRXMatch( &Pattern , &VarName ) ) > 0 ) %Then %Do ;
%Let VarList = &VarList &VarName ;
%End ;
%End ;
%Let Close = %SysFunc( Close( &DSID ) ) ;
%If ( %Length( &VarList ) EQ 0 ) %Then %Do ;
%Put ;
%Put ;
%Put NOTE: Could Not Find A Variable That Matched Pattern. ;
%Put ;
%Put ;
%End ;
&VarList
%Mend VarMatch ;
Example: Data Have ; ABDC = 1 ; ABCD = 2 ; XYZC = 3 ; ABFC = 4 ; Run ; Title "Print Out For Vars Ending With C" ; Proc Print Data = Have ; Var %VarMatch( DSN = Have , Pattern = *C ) ; Run ; Output: Print Out For Vars Ending With C Obs ABDC XYZC ABFC 1 1 3 4
|
hi this is very good side to learn technical matter so visit and enjoy modern life
Mily
<a href="http://snipurl.com">
|
Macro In FunctionIn the Data Step world there is the In function. Up until recently there was for this ever so helpful little function. The SAS tried in version 9 to create one at the users request #In. However, since the # was a free character for so long that many programmers used this for all sorts of things like a separator for Macro list. Not too suprisingly it made many older programs bomb and well that breaks a SAS golden rule of always making code backwards compatible. So they disabled this feature, but Tech support was still getting calls wanting such a feature. Tech Support has this for there code:
%macro in()/parmbuff;
%local i;
%let parms=%qsubstr(&syspbuff,2,%length(&syspbuff)-2);
%let var=%scan(&parms,1,%str(,));
%let numparms=%eval(%length(&parms)-
%length(%sysfunc(compress(&parms,%str(,)))));
%let infunc=&var eq %scan(&parms,2,%str(,));
%do i= 3 %to (&numparms + 1);
%let thisparm=%scan(&parms,&i,%str(,));
%let infunc=&infunc or &var eq &thisparm;
%end;
(&infunc)
%mend;
All I can say is Yuck!!!! who walked in and spewed that hunk of crap!!!! So I wrote my own which is simplier and actially has some error handling.
%Macro IsIn( LookFor= , List= , Case=I ) ;
/***************************************************/
/** Name : IsIn **/
/** **/
/** Parameters : LookFor ~ Text To Search For In **/
/** Target String (List). **/
/** **/
/** List ~ Target Sting To Search **/
/** **/
/** Case ~ Determines Whether The **/
/** Search Is Case **/
/** Sensitive **/
/** I = Case Insensitive **/
/** Blank = Case Sensitive **/
/** **/
/** Purpose : The Macro Version Of The In **/
/** Function. Returns 1 If It Can **/
/** Find The Text And 0 If It Cant **/
/***************************************************/
%Local Pattern ;
%If ( %Length( &LookFor ) = 0 ) %Then %Do ;
%Put ;
%Put ERROR: Please Specify A Valid Value For The LookFor Parameter!!! ;
%Put ;
%Return ;
%End ;
%If ( %Length( &List ) = 0 ) %Then %Do ;
%Put ;
%Put ERROR: Please Specify A Valid List Of Values For The List Parameter!!! ;
%Put ;
%Return ;
%End ;
%If ( ( %Length( &Case ) Ne 0 ) And ( &Case NE I ) And
( &Case NE i ) ) %Then %Do ;
%Let Case = I ;
%Put ;
%Put WARNING: The Value For Parameter Case Is Not Valid. ;
%Put WARNING: A Value Of I Will Be Used Instead. ;
%Put ;
%End ;
%Let Pattern = %SysFunc( PRXParse( /(?=&LookFor)/&Case ) ) ;
%Eval( %SysFunc( PRXMatch( &Pattern , &List ) ) > 0 ) ;
%Mend IsIn ;
|
Breaking A Data Set Into N Number Of Data Sets
/***************************/
/** Create Some Data **/
/***************************/
Proc Summary
Data = SASHELP.prdsal3 NWay ;
Class Country State ;
Output Out = Sums ( Drop = _Freq_ _Type_ ) Sum( Actual ) = Sales ;
Run ;
/********************************************/
/** Because The Hash Method Shown Below **/
/** Requires An Explicit List Of Variables **/
/** To Be Included In The OutPut Data Sets **/
/** This Macro Variable Is A Sort Cut So **/
/** That They Do Not Have To Be ard Coded. **/
/********************************************/
Proc SQL NoPrint ;
Select Quote(Strip(Name)) Into : VarNames Separated by ' , '
From Dictionary.Columns
Where LibName = 'WORK'
And MemName = 'SUMS' ;
Quit ;
Data _Null_ ;
If 0 Then Set Sums ;
DCL Hash Countrys ( Ordered: 'A' ) ;
Countrys.definekey ( 'Country' , '_N_' ) ;
Countrys.definedata ( &VarNames ) ;
Countrys.definedone () ;
Do _N_ = 1 By 1 Until ( Last.Country ) ;
Set Sums ;
By Country ;
Countrys.Add() ;
End ;
Temp = Compress( Country , '.' ) ;
Countrys.Output ( DataSet: Temp ) ;
Run ;
|
Part 1 of 3This is Part 1 of a 3 part series on advanced Macro programming. Most programmers who use Macros only think of a Macro as a means to reproduce Data Step or Procedure code with minor tweaks. This mind set for beginning programmers is a good thing, however as a programmers ability increases there arises a need to have a macro read a Data Set, read a external file, or write to an external file entirely in pure Macro code.
%Macro GetValues( DataIn = , Variable = ) ;
%Local DSID GetNextObs GetVarNum Close I ;
%Let DSID = %SysFunc( Open( &DataIn , I ) ) ;
%Do I = 1 %To %SysFunc( Attrn( &DSID , NLOBS ) ) ;
%Let GetNextObs = %SysFunc( FetchObs( &DSID , &I ) ) ;
%Let GetVarNum = %SysFunc( VarNum( &DSID , &Variable ) ) ;
%SysFunc( GetVarC( &DSID , &GetVarNum ) )
%End ;
%Let Close = %SysFunc( Close( &DSID ) ) ;
%Mend GetValues ;
%Put %GetValues( DataIn = SASHELP.CLASS , Variable = Name ) ;
There are a few things that one needs to know to read a data set with pure macro code. First is how to open and close a Data Set. For this we use the Open and Close functions. Since these are not Macro functions we need away to get the Macro facility to interface with them, so we see %Sysfunc which allows us to do just that. It is important to note that you cannot forget to Close your Data Set. By default all Data Sets are closed at the end of a Data Step, however you aren’t in that environment so it is left to, you, the programmer to close the Data Set. If you do forget to Close your Data Set you will not be able to use the Data Set again until Close it or restart your SAS session. This is due to the fact that when you open a Data Set in this manner you lock it down until you specifically release it for further use. Next we use the Attrn function to retrieve the number of observations in the Data Set. In a normal Data Step there is an implicit loop which cycles through the observations for you. Since we don’t have that implicit loop we need to construct our own loop and thus need specify how many times we want to loop through the Data Set. In a Data Step we have the Program Data Vector which is were the data is brought into and manipulated while the Data Step is running before writing the data out. We also need such a space and to do this we use FetchObs which gets the observation specified in the second argument and brings its value(s) into what is called the Data Set Data Vector. Now that we have an observations value in a place we can retrieve it we need to specify which variable’s value we want to retrieve. For this we use the VarNum function, which when passed the Data Set Id and variable name will return the variables position in the Data Set. Finally we can retrieve the variables value with GetVarC which gets character variables values from a Data Set and returns said value to a Macro variable. If one wanted to retrieve a numeric variables value then use GetVarN. Last but not least after all observations are processed we close the Data Set with the Close function.
|
Part 2 of 3 "A Macro That Reads All Files In A Directory"
%Macro GetFiles( FilePath= ) ;
%Local MyFile FileName DSID I Close ;
%Let MyFile = MyDir ;
%Let FileName = %SysFunc( FileName( MyFile , &FilePath ) ) ;
%Let DSID = %SysFunc( DOpen( &MyFile ) ) ;
%Do I = 1 %To %SysFunc( DNum( &DSID ) ) ;
%SysFunc( DRead( &DSID , &I ) )
%End ;
%Let Close = %SysFunc( DClose( &DSID ) ) ;
%Mend GetFiles ;
We need to allocate the directory to a file statement. To do this and keep it all in pure macro code, we use the FileName function. Like the last macro, we need to open the directory so that we can read all the file names. In the last macro, we used the Open function which works on SAS datasets, not directories. So SAS has the DOpen to open a directory. We need to count the number of files in the directory and for that we have Dnum, which returns the number of files in the directory. Next we use the DRead function to read a file name. Finally, we use the DClose to close the directory.
|
Part 3 of 3 "A Macro That Creates And Writes Data To A Text File"
%Macro Write2File( FileOut= ) ;
%Local File FileName FileId I Text Write Close ;
%Let File = MyFile ;
%Let FileName = %SysFunc( FileName( File , &FileOut ) ) ;
%Let FileId = %SysFunc( FOpen( &File , O , , P ) ) ;
%Do I = 1 %To 50 ;
%Let Text = %SysFunc( FPut( &FileId , &I ) ) ;
%Let Write = %SysFunc( FWrite( &FileId ) ) ;
%End ;
%Let Close = %SysFunc( FClose( &FileId ) ) ;
%Mend Write2File ;
%Write2File( FileOut = C:\Documents and Settings\Toby Dunn\Desktop\ABC.TXT )
%Let File = MyFile ; Creates a alais for the file, it is just like the alias one would use in a normal FileName statement in any SAS program. %Let FileName = %SysFunc( FileName( File , &FileOut ) ) ; Alocates a FileName Statement with the alias in the macro variable File. The FileOut macro variable contains the path and the name of the output file with its extension.
%Let Write = %SysFunc( FWrite( &FileId ) ) ; Physically writes the text in the macro variable Text to the created file.
|
