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 =...
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...
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.
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...
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...
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...
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) !! '/' ...
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...
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...
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...
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...
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.
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?
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.