09-01-2015
Robert_Bardos
Fluorite | Level 6
Member since
06-23-2011
- 106 Posts
- 0 Likes Given
- 0 Solutions
- 13 Likes Received
-
Latest posts by Robert_Bardos
Subject Views Posted 1267 12-24-2012 06:01 AM 1200 12-10-2012 03:27 AM 3174 12-09-2012 03:43 AM 1372 12-09-2012 03:20 AM 1457 12-08-2012 03:04 AM 1556 12-07-2012 06:59 AM 1609 12-06-2012 06:59 AM 1142 12-06-2012 05:22 AM 2445 12-05-2012 04:06 AM 2445 12-05-2012 01:56 AM -
Activity Feed for Robert_Bardos
- Got a Like for Re: Adding days to a DATETIME value?. 04-22-2018 08:15 PM
- Got a Like for Re: ods tagsets.excelxp - one excel with few worksheets. 09-01-2015 04:24 AM
- Got a Like for Re: Recording an observation. 09-01-2015 04:24 AM
- Got a Like for Re: Excel Report ( Conditional formatted) as attachment in Email. 09-01-2015 04:24 AM
- Posted Re: Resolving numeric condition on SAS Programming. 12-24-2012 06:01 AM
- Posted Re: Recording an observation on SAS Programming. 12-10-2012 03:27 AM
- Posted Re: Excel Report ( Conditional formatted) as attachment in Email on SAS Programming. 12-09-2012 03:43 AM
- Posted Re: Recording an observation on SAS Programming. 12-09-2012 03:20 AM
- Posted Re: subsetting if statement on SAS Procedures. 12-08-2012 03:04 AM
- Posted Re: Cutting a String on SAS Procedures. 12-07-2012 06:59 AM
- Posted Re: ods tagsets.excelxp - one excel with few worksheets on SAS Programming. 12-06-2012 06:59 AM
- Posted Re: Retain Question on SAS Programming. 12-06-2012 05:22 AM
- Posted Re: Reading text string (variable length) on SAS Procedures. 12-05-2012 04:06 AM
- Posted Re: Reading text string (variable length) on SAS Procedures. 12-05-2012 01:56 AM
- Posted Re: Reading text string (variable length) on SAS Procedures. 12-04-2012 12:10 PM
- Posted Re: Reading text string (variable length) on SAS Procedures. 12-04-2012 04:56 AM
- Posted Re: Data Step Events on SAS Programming. 12-04-2012 04:51 AM
- Posted Re: proc format on SAS Procedures. 12-03-2012 07:26 AM
- Posted Re: Adding days to a DATETIME value? on SAS Data Management. 12-03-2012 07:18 AM
- Posted Re: proc format on SAS Procedures. 12-03-2012 06:28 AM
-
My Liked Posts
Subject Likes Posted 1 12-03-2012 07:18 AM 3 12-06-2012 06:59 AM 3 12-10-2012 03:27 AM 3 12-09-2012 03:43 AM
12-24-2012
06:01 AM
Jag is right insofar as you should try to get an unquoted (ie. numeric) value for &nbObs. There is a solution however even when &nbObs has the value (quotes being part of the value) "23" %if %eval ( %sysfunc(dequote(&nbObs)) > 6 ) %then %do ; This first removes the quotes from &nbObs and then does the %eval part. But as mentioned initially (giving credit to Jag): try to get a pure numeric value for &nbObs first. Regards Robert
... View more
12-10-2012
03:27 AM
3 Likes
Great! Thanks, data _null_, now that I have access to "my" z/OS system again, I verified that both search type functions (WHICHC/WHICHN) though not documented do work with SAS 9.1.3 as well (z/OS 1.12 here with SAS 9.1.3, &sysvlong displaying - retyped - 9.01.01M3P020206). Added the 9.2 categorized list of functions to my bookmarks.
... View more
12-09-2012
03:43 AM
3 Likes
Undoubtedly one of the best resources for questions of this type: Chevell Parker from SAS Read e.g. http://www2.sas.com/proceedings/sugi31/091-31.pdf having a small section on emailing HTML documents directly from SAS. For a more refined search start at Lex Jansen's Homepage by entering some of the buzzwords your are looking for in its Search box. Robert
... View more
12-09-2012
03:20 AM
Hi "Bhpinder", basically you are doing the right thing, but yes, it can be improved. to exit a do loop use the LEAVE statement (i.e. you can drop GOTO and its target label) use 'do i=1 to dim(check);' thus bypassing hard coding the number of elements in the array further possibilities for improvement: loop exit can also be controlled on the DO statement itself, so look up DO UNTIL and DO WHILE respectively some people prefer using automatic variables (e.g. _n_) for the loop counter because _n_ is automatically dropped i.e. not written to the eventual dataset modifying _n_ does not interfere with the way _n_ gets assigned by the datastep's internal mechanisms so it can be used rather freely (Don't waste too much time thinking about this statement if its meaning is not immediately understandable. I'm sure it can be expressed much better but I'm getting to my limits here with regards to my command of the english language.) (PS: I'm not an advocate of this use of _n_ as it might confuse people for whom SAS is but one of the many tools they use.) Generally I strongly advice to bookmark SAS online documentation. My favourite (not having had access to any SAS system above 9.1.3) being - you guess it - the 9.1.3 Documentation and there especially the Language Reference Dictionary book. SAS has such a rich set of functions, formats, informats, options and statements that skimming through its pages is time well invested. Furthermore there are overview pages in this document such as Functions and CALL Routines : Functions and CALL Routines by Category that I always turn to when a voice inside me says "there must be some function, format, whatsoever that exactly does this". Kind regards Robert
... View more
12-08-2012
03:04 AM
Comments in SAS can be of the form /* comment enclosed in slash-asterisk and asterisk-slash respectively */ * comment as per "if the first nonblank character after a semicolon (or when it is the very first character in the entire source code) is an asterisk then everything up to the next semicolon will be treated as a comment" ; %* comment in macro language syntax. Similar rule as before applies, ie. has to be terminated by a semicolon and has to come first after a statement boundary ; Now all this is extremely abbreviated and subject to omissions/errors that my fellow peers will eventually point out. What it boils down to in the context of your question: The "bold statement" is nothing but a comment that tries to explain the non-bold statement (ie. the subsetting if) to its left. Hope this makes sense Robert
... View more
12-07-2012
06:59 AM
Try HEADER = put(SHRCD,best.-l) ; If that works then a bunch of the assumptions that we had to make (since you provided no log) could be true. Assumptions such as SHRCD is numeric and not character So the log would have told us by mentioning 'Numeric values have been converted to character ...' "Header will have no observations" should be "Header will be blank" Happens when SHRCD is numeric and the value is per default right justified in an eight byte field of which you extract (by means of SUBSTR) position one i.e. a blank Now why would the above work without invoking function SUBSTR? That's because the length of HEADER has already been declared as one byte. (Note BTW the statement has to be "length header $1", i.e. no dot after $1 . We are declaring the length here and not assigning a format.) Transferring a longer character variable's value to a shorter variable results in the value being truncated at the shorter variable's length. Oh, and "best.-L" means: "write out the numeric value justified left in a format optimal for the field length". Hope this heaps Robert
... View more
12-06-2012
06:59 AM
3 Likes
It's been a while since I used tagsets.excelxp so I may be totally off track. Studying your log I see that both a HTML and an XLS file are being created for both your PROC PRINTs. If that is how it should be and has always been then disregard my question, which is: Have you always had an open HTML destination when creating your excel files? (This is in the spirit of the eternal question "what changed?" when someones post a "last time it worked" type of question.) Robert
... View more
12-06-2012
05:22 AM
You could construct a macro variable containing the list of the _m prefixed variables prior to the datastep and feed that list into the RETAIN statement. Somewhat like proc sql noprint ; select name into :mlist separated by ' ' from dictionary.columns where upcase(libname)='WORK' and upcase(memname)='IN_FILE1' and upcase(name) eqt '_M' ; quit ; data new_file ; retain _name _step &mlist new_month; /* rest of your code */ run ; Unless I totally screwed up my tests (on z/OS, SAS 9.1.3) that should work. (Caveat: due to cut/paste being restricted on my z/OS connection, I had to retype the above code by hand.) Robert Missing closing quote added after "='IN_FILE1" in SQL step. (Robert, 07dec2012:07:08 GMT+1)
... View more
12-05-2012
04:06 AM
With regards to the hash table approach this begs the question whether (and I am talking about every day's reuse of the data here) the hash table can be hardened to a storage medium such that keyed access to a single item is possible without reloading the entire table first. Imagine a multimillion rows table with an index on one or more variables. Which one is more effective: accessing the desired row with a keyed access directly from the storage medium or loading the hash table into memory first and then doing a find on it? I guess it boils down to a "it depends". Note that I have close to zero experience with hashes but from what I've read (code samples in SAS-L mainly) I'm under the impression that they aren't the swiss army knife for every data retrieval problem.
... View more
12-05-2012
01:56 AM
Sorry Ksharp, seems I was too scarce with my comment. What I'm trying to convey: ^'model' and 'make' are difficult to parse out when the only delimiter between them are blanks examples: 'alfa romeo giulia', 'sunbeam talbot alpine', 'steyr puch haflinger' where 'model' consists of the first two words examples with more than two words designating 'model' are imaginable though I can't name one off the top of my head values requiring special treatment should not be hard coded in programs but stored in tables much rather i.e. sequences of "if lowcase(scan(_infile_,1)) = 'alfa' then ....' statements in the program source tend to become a maintenance nightmare Still unclear? Robert
... View more
12-04-2012
12:10 PM
Well, it's no doubt doable. That wasn't the goal of the question. Rather to raise the awareness that the problem as it was presented is difficult to solve without some kind of lookup table containing manufacturer's names. Although I can't name one off the top of my head, mergers may have created names consisting of three or more parts.
... View more
12-04-2012
04:51 AM
Hi Mahesh, Is there such a way? Not that I knew. (As if that meant a lot 😉 ) However you could create a macro replacement to the RUN and QUIT statement respectively. Somewhat like this: %macro static_macro ( called_after = NONE ) ; %put &sysmacroname called after &called_after ; %mend static_macro ; %macro rq (rq_cmd) ; %local _sp ; %let _sp = &sysprocname ; &rq_cmd ; %static_macro ( called_after = &_sp ) ; %mend rq ; data _null _ ; put 'Note: Message from datastep.' ; %rq ( run ) ; proc sql noprint ; select max(age) as max_age from sashelp.class ; %rq ( quit ) ; So not an EVENT like solution, much rather a workaround. BTW: you could get fancier by using automatic macro variable &SYSPROCNAME but I think coding RUN/QUIT as an argument of the RQ macro enhances readability. Kind regards Robert
... View more
12-03-2012
07:26 AM
(I'm referring to my earlier reply) So if you want numbers identified with the hard coded string 'number' then simply change if not notdigit(compress(your_char_var,' .')) and not missing(input(your_char_var,?? 8.)) then your_char_var = compress("'"!!your_char_var!!"'") ; to if not notdigit(compress(your_char_var,' .')) and not missing(input(your_char_var,?? 8.)) then your_char_var = 'number' ; BTW: the "table" as you refer to PROC PRINT's output was intended as an aid in following the logic.
... View more
12-03-2012
07:18 AM
1 Like
I'd use one of SAS's most powerful date/datetime functions: INTNX Somewhat like %let filterdate_end = %sysfunc( intnx( dtday, "&filterdate_start"dt, 2 ) , datetime20. ) ; Two assumptions here: &filterdate_start is the formatted datetime value, &filterdate_end is expected to be in datetime20. format. If not then %let filterdate_end = %sysfunc( intnx( dtday, &filterdate_start, 2 ) ) ; will do and return the result as the number of seconds since SAS epoch (formatting then left to you).
... View more