09-01-2015
TimArm
Obsidian | Level 7
Member since
11-21-2012
- 29 Posts
- 2 Likes Given
- 0 Solutions
- 18 Likes Received
-
Latest posts by TimArm
Subject Views Posted 2302 05-14-2015 06:12 AM 10272 05-15-2013 11:30 AM 2904 05-15-2013 04:12 AM 38362 05-02-2013 08:42 AM 38362 05-02-2013 06:44 AM 3629 05-01-2013 10:20 AM 1590 05-01-2013 07:07 AM 24340 04-30-2013 09:01 AM 3173 12-20-2012 09:09 AM 3080 12-06-2012 09:27 AM -
Activity Feed for TimArm
- Got a Like for Re: how to read filenames of a directory into a file. 03-14-2022 04:36 PM
- Got a Like for Re: how to read filenames of a directory into a file. 07-12-2018 09:57 AM
- Got a Like for Re: how to read filenames of a directory into a file. 10-20-2017 02:34 PM
- Got a Like for Re: remote macro variables in local code. 09-01-2015 04:24 AM
- Got a Like for Re: Please Help with the error on Array "ERROR: Array subscript out of range at line ~ column ~ . ". 09-01-2015 04:24 AM
- Posted Re: How to read observations in multiple records conditionally on SAS Programming. 05-14-2015 06:12 AM
- Got a Like for Re: how to read filenames of a directory into a file. 01-23-2014 02:16 PM
- Posted Re: Removing linefeeds on SAS Procedures. 05-15-2013 11:30 AM
- Posted Re: Copy/move external file,doesn't work. on SAS Programming. 05-15-2013 04:12 AM
- Posted Re: Removing space while resolving macros on SAS Programming. 05-02-2013 08:42 AM
- Liked Re: Removing space while resolving macros for Ksharp. 05-02-2013 08:42 AM
- Posted Re: Removing space while resolving macros on SAS Programming. 05-02-2013 06:44 AM
- Posted Re: Running SAS EG jobs in Windows from Unix on SAS Programming. 05-01-2013 10:20 AM
- Got a Like for Re: Can someone help me with my formatting?. 05-01-2013 07:26 AM
- Posted Re: Can someone help me with my formatting? on SAS Programming. 05-01-2013 07:07 AM
- Got a Like for Re: Add a certain number of days onto a date. 04-30-2013 04:37 PM
- Posted Re: Add a certain number of days onto a date on SAS Programming. 04-30-2013 09:01 AM
- Got a Like for Re: how to calculate the max length of an observarion and assign it the max maxmium length .... 12-20-2012 04:07 PM
- Posted Re: how to calculate the max length of an observarion and assign it the max maxmium length ... on SAS Procedures. 12-20-2012 09:09 AM
- Posted Re: excel to SAS dataset in UNIX on Microsoft Integration with SAS. 12-06-2012 09:27 AM
-
Posts I Liked
-
My Liked Posts
Subject Likes Posted 3 11-21-2012 10:02 AM 3 11-21-2012 10:55 AM 4 11-21-2012 09:41 AM 1 05-01-2013 07:07 AM 1 04-30-2013 09:01 AM
05-14-2015
06:12 AM
In my experience, this kind of problem usually requires stripping out carriage returns using a preprocessing step. I use the following macro: %macro replace_crlf(inf,repchar='.'); data _null_; infile "&inf." recfm=n sharebuffers; file "&inf." recfm=n; input a $char1.; retain open 0; ** This statement toggles the open flag. ; if a='"' then open=not open; if a in ('0A'x,'0D'x) and open then put &repchar.; run; %mend replace_crlf; %replace_crlf(filename.csv,repchar=' '); This will alter the file in place...so if you don't want to risk losing the original, take a copy of it first! Good luck.
... View more
05-15-2013
11:30 AM
Try using v1= TRANSLATE(v1,"",'0A'x); The function TRANWRD looks for white space to delimit words - so probably considers '0A'x as white space. NOTE: the arguments to TRANSLATE need to be swapped around from TRANWRD. Tim
... View more
05-15-2013
04:12 AM
Hello. Try this and check the values of rc: data rc; rc=system("xcopy \\133.9.206.139\bdp\43430710\Test\a.xls \\133.9.206.139\bdp\43430710\Test\test1"); output; rc=system("move \\133.9.206.139\bdp\43430710\Test\a.xls \\133.9.206.139\bdp\43430710\Test\test1"); output; rc=system("copy \\133.9.206.139\bdp\43430710\Test\a.xls \\133.9.206.139\bdp\43430710\Test\test1"); output; run; Once you get something that works you can try it again in %sysExec, or keep the above with data _NULL_ instead of data rc (although it can be quite useful to have a work dataset where you can check the return codes). If you have a drive mapping for \\133.9.206.139\bdp then try using that instead. Tim
... View more
05-02-2013
06:44 AM
Hello santhosh, I think this is a simple solution you could try... data _null_; set temperv end=eof; length t_str $100.; t_str = cats('CPRNO',put(_n_,10.)); call symput(t_str,CPRNO); if eof then t_str = left(put(_n_,20.)); call symput('numrows',t_str); run; %put _user_; Regards, Tim
... View more
05-01-2013
10:20 AM
Hello John, On our unix server we have Samba installed so that we can access the same disk area from unix and Windows. Do you have samba installed - or is it something you can ask your Unix Administrator to install? This means I can edit a file on Windows as X:\sharename\file.sas, and then include it from a job running on unix as /usr/data/sharename/file.sas Regards, Tim
... View more
05-01-2013
07:07 AM
1 Like
I think you were almost there. Try this... Data comb_rate; Set female_pr male_pr pulserate; label rate_change='Pulse Rate Change' BMI='Body Mass Index'; if gender='male' then do; BMI=703*weight/(height*height); end; if gender='female' then do; BMI=695*weight/(height*height); end; Rate_change=rate_after-rate_before; run; proc print data=comb_rate; run; proc format; value bmifmt Low-25='Normal' 26-35 ='Low Risk' 36-High='High Risk'; run; proc print data=comb_rate label; FORMAT BMI bmifmt.; run;
... View more
04-30-2013
09:01 AM
1 Like
I would do it like this... data test; attrib fromdt length=8. format=DATE9. todt length=8. format=DATE9. ; fromdt = "03MAR2010"d; todt = intnx('DAY',fromdt,60); run;
... View more
12-20-2012
09:09 AM
1 Like
Hello ajuhack, I have attached 3 macros that you might like to try. The main macro is called %read_csv_data.sas - it calls the other 2 macros. I have learned by experience not to trust proc import for the very reason that it uses guessingrows. If you are guessing, you will always run the risk of data truncation. My solution is to perform 2 passes (in the way Cynthia suggested). Actually, because of my environment, it also reads the top 100 lines first, before doing the full reads, to determine if lines are CRLF or LF terminated! It searches the top 100 lines for a header record, in order to work out column names. It searches for a delimiter, or you can specify it if you know it. It reads all of the data into character variables - so you will need to convert numerics and dates afterwards. In my test file of 95,000 obs it takes about 1 minute to run on my AIX server. My other test file of 410MB and over 10 million obs takes 8 or 9 minutes. SAS is good like this - the first full read of the text file takes 7.5 minutes, and the second read takes 40 seconds. I hope you find this useful. Tim.
... View more
12-06-2012
09:27 AM
I also agree with SASKiwi; I cannot use proc import with Excel files on my AIX server. If you are using a data step, you could try using the termstr=CRLF option on the infile statement - if your file was saved on a Windows platform. SandorSzalma is correct that you can still use proc import on unix, as it can still be used to read text files (delimited). HOWEVER, if you use proc import with a tab delimited file it only looks at the first 2 rows by default to guess variable lengths. You can change this by using the GUESSINGROWS= option.
... View more
12-06-2012
05:28 AM
To try to answer your original question, have you tried this?... data out; set ordered (obs=0); ... run; If you include the ordered dataset as the first in the set statement, but with obs=0, it should define the variables you want in the order you want.
... View more
11-27-2012
10:56 AM
Actually, I suggested another approach...but I don't have time to time it
... View more
11-26-2012
08:09 AM
This should run as quickly as Tom's SQL, I hope (although it is more verbose!): data lastonly (drop=t_:); set have (rename=(ColA=t_A ColB=t_B ColC=t_C)); by Period; length ColA ColB ColC 8.; retain ColA ColB ColC; if first.Period then do; ColA = .; ColB = .; ColC = .; end; ColA = max(ColA,t_A); ColB = max(ColB,t_B); ColC = max(ColC,t_C); if last.Period then output; run;
... View more
11-26-2012
05:17 AM
In that case, if you want to reset the syserr value each time, change the %runquit macro to: %macro runquit; %* Reset the syserr value; data _null_; x=x; run; %mend runquit;
... View more
11-22-2012
04:59 AM
min(7,income_dx) - that's an Astoundingly good suggestion. I like it. I have another alternative, though - use a format to map the value of income_dx to an array index. With a format you could catch values for income_dx that are not in 1,2,3,4,5,6,9 and assign them to another array index for data "errors". A format would also let you convert the character income_dx to a number without creating another variable.
... View more