Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by MatthiasB

  1. MatthiasB

    Question about Dow-Loop SAS code

    This likely is a problem how you compare floating point numbers. Depending on how you generate your numbers on the way to the ADSK table, you could introduce some inaccuracy. Check this: 401 data _null_; 402 base = 5; 403 divide = 3333333; 404 aTear = base / divide; 405 aBucket =...
  2. MatthiasB

    Moving multiple rows to single row

    Quite some time ago, maybe still current - try something like this: proc sort data=oldTab; by tiliA tiliB; run; data newTab; set oldTab (rename=(tiliB=oneB)); by tiliA; length tiliB $50; /* or whatever length you need */ retain tiliB; if first.tiliA then tiliB = left(oneB); else...
  3. MatthiasB

    create new variable based on next row

    You can retain the >new< variable batch_id and increment it according to the specified condition, e.g. retain batch_id 0; if job_id eq 1 then batch_id = batch_id+1; Plug it into your datastep and you should have the batch_id set properly.
  4. MatthiasB

    Skip over variables when importing flat file into sas

    I tend to provide lengthy solutions, yet this makes sure you can handle these optional cases. Principle problems with you data are an optional variable placed on the data line, plus you have no delimiter between drug and manufacturer; I assume the drug is a single word, but that seems to not be...
  5. MatthiasB

    Macro to automate selection of multiple files with similar name

    Always remember that macro is used to make repetitive things easier, the repeating bits you can loop and/or parametrize for example. You have the year and the number of consecutive files as variable parts, so assuming the library and file names are fix, just add those two to the macro...
  6. MatthiasB

    HELP!!! Create Duplicate records using SAS!

    @jj72uk d(^_^)b shorter, true. Always forget about "do" w/o init and inc lines. Back to the tele again, "supernatural-on-dvd" time.
  7. MatthiasB

    HELP!!! Create Duplicate records using SAS!

    Try something like this to take firstTable and turn it into the larger secondTable (both in WORK library). The "greater-equal" comparison makes sure you do not have an endless loop on days smaller 1. data WORK.secondTable; set work.firstTable; length visit 8; visit = 1; do until (visit...
  8. MatthiasB

    Date Format

    Hi, See in PDF "SAS Language Reference: Dictionary" in "Chapter 3: Formats" the section on MMDDYYw. format for details. data _null_; length txtDate $5 numDate 8 ; /*-- as text - not so nice */ txtDate = '0225'; txtDate = substr(txtDate,1,2) !! '/' ...
  9. MatthiasB

    data step or proc sql for performance time

    Thousands of records isn't so bad, I don't think you will see much difference either way - unless sitting on >really< slow CPUs and I/O. You'd need more complex joins and lookups with 100k's or millions of records crossed with thousands to see a real difference. Then things like "SET KEY=" on...
  10. MatthiasB

    Parsing in SAS

    Hi SAP1958, should go in under 60 lines of code, get introduced to SAS/Macro: %* MACRO - read all files w/pattern FP in folder BDIR ; %* store the vautil files in table DS ; %macro rdVAUTIL (bdir=, fp=, ds=); %local numFiles; %let numFiles=0; %*-- find all files to...
  11. MatthiasB

    Parsing in SAS

    Just specify the funny 3 as a delimiter on the infile and you're set. I also suggest to specify the length of all variables on introduction - it's good practice and avoids any issue with cut-off strings or similar: data VAUTIL03; length STATE $2 NDC1 8 NDC2 8 NDC3 8...
  12. MatthiasB

    Data step sort vars by # decimal places

    You can turn the number via format to a string w/o trailing zeros and remove punctuation with compress. Below example assumes you have max width of 5 characters incl a potential dot. data x; val = 23.45; output; val = 23.4; output; val = 23.; output; run; data _null_; set x; length...
  13. MatthiasB

    selecting fields with spaces and slashes

    These should be no physical SAS columns, they look like column labels of a table view. Spaces, slashes etc are surely invalid (SAS) name characters. You have to get the column names and make the query, then it'll work.
  14. MatthiasB

    fill missing variables by cycle

    I don't get the rule for filling the f* h* columns. With knowing that and knowing how to reverse order (or using a counter _n_ variable to sort reverse), it shouldn't be hard to retain the values to fill any missing. Can you let us known the rules?
  15. MatthiasB

    converting a date in sas

    Just to make sure: the SAS format basically changes the >output< format, it does not change the content of the variable. You read in a datetime, you want date only displayed. Add line "BirthDate = datepart(BirthDate);" and you should be set. Cheers, Matthias

Part and Inventory Search

Back
Top