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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: kdt82
  • Order by date
  1. kdt82

    Matching regions

    Hi kushiwije, Can you provide a clearer example? How does your dataset look at the moment? It would help us identify the crux of the problem if you can provide a brief illustration of how your data is, and how you want it to be. Thanks
  2. kdt82

    Identifying data where month is not equal to specified month

    Hi STrookie, The month function will return the integer month from a SAS date. So you can subset for dates not on the 9th month: *display dates not in September(month 9) ; if month(nipr_exp_dt1) ne 9 ;
  3. kdt82

    Set permissions when creating a dataset

    Hi Tariq, When creating the dataset you have the ability to password protect aspects of it. For example, you can set separate passwords for reading, writing and altering the dataset/view. Alternatively, you can use the pw keyword to assign a full lock on your dataset. data...
  4. kdt82

    create new variable with do loop

    Hi Chris, As far as I know, the SAS do loop is comparable to the C for loop. Syntatically it is a bit different. For eg. The C for loop: #include<stdio.h> int main() { int i; for (i = 0; i < 10; i++) { printf ("Hello\n"); printf ("World\n")...
  5. kdt82

    create new variable with do loop

    Hi Chris, You almost have it with your last row, but why the looping? if mod(i,3) = 1 then reset, otherwise add 1 data iris1; input m1-m4 @@; count ++ 1; if mod(_n_,3) = 1 then count = 1; cards; 5.1 3.5 1.4 0.2 7.0 3.2 4.7 1.4 6.3 3.3 6.0 2.5 4.9 3.0 1.4 0.2 6.4 3.2 4.5...
  6. kdt82

    How to read delimited data with datalines ?

    Hi Chris, Try placing the dsd option on the infile line. The dsd option will treat two consecutive delimiters as a missing value. I would also add the missover option in case you have missing values at the end of the line. data test1; infile datalines dsd missover ; input n1 n2 n3 ...
  7. kdt82

    How to get only the last row

    Try using last. data have ; input name :$1. dateperiod :$6. ; cards ; A 200301 A 200901 A 201001 B 200801 B 200901 B 201001 ;;;;; data want ; set have ; by name notsorted ; if last.name ; run; proc print;run;
  8. kdt82

    Help: using SAS Macro to create complex data set

    Not something that I would try to solve with Macro, but definately better handled with the datastep or SQL. Here is an approach that uses a cartesian product (compare every record with every other record), and then whittles the list down based on the criteria you mentioned above. We get some...
  9. kdt82

    Finding various means per group

    SAS has many was to do this type of thing. Here is an example using proc summary/means data have ; input Group ID Successes ; cards ; 1 1 3 1 2 10 1 3 4 2 1 3 2 2 8 2 3 2 3...
  10. kdt82

    Birthdate calculation not working

    Hi Sap1958, Before you go any further, please note that: Age = intck('year',datepart(Birthdate),date()); is the incorrect way to calculate age in SAS as it won't provide the correct age if the day of birth is after todays day. For example, try running the following code and see if it...
  11. kdt82

    Renaming a list of variables

    As you have already noted, given the names of your variable, you cannot rename with a variable list. I would consider using a combination of SQL and the dictionary tables to generate the rename code. Example using sashelp.class data have ; set sashelp.class ; run; proc sql noprint...
  12. kdt82

    Conversion to currency

    You can't "convert" anything to currency as there are only 2 datatypes in SAS: Numeric and Character. You can however, permanantly associate a format to display that variable as currency. Simply replace 'put' with 'format' in your example. data tblCustomer1; set tblCustomer; if Salary...
  13. kdt82

    Dates and if/then else

    If CE_DUE_DT has to always be the last day of the previous month (relative to the date being passed to it), I would recommend using the Intnx function to get the first day of that month and subtract 1 to get the last day of the previous month. Example data _null_ ; date = '01SEP10'd ...
  14. kdt82

    What does ++ mean?

    Hi Riskassure, This is look-ahead code. The ++ performs the same operation as +. Some programmers prefer to use this syntax on sum statements so that it stands out. Consequently _n_ +_n_ < n will work just as well. The second part of the expression: _n_<n resolves to a boolean value (i.e 1...
  15. kdt82

    Creating new variables without any data

    Do you want to create blank character variables or numeric variables? From your first post, I assume you mean numeric variables. SAS uses the period to highlight the missing variable is of type numeric, so other than using a format, I don't think you can change the appearance to a blank in the...
  16. kdt82

    Creating new variables without any data

    In the normal data step, the trick is to stop SAS from returning to the top of the implicit loop. Metadata attributes get defined at compilation time, so you can define variables with formats, labels and lengths without having any records. data step: data blank1 ; dummy1 =''; dummy2 =...
  17. kdt82

    proc sql &quot;top x&quot; in subquery

    Hi, For your particular issue, I would try a subquery like this proc sql; select id, (select address from tab_b b where b.id = a.id having max(date)=date ) as last_address from tab_a a; Here is some test data and code I used to get the last sale...
  18. kdt82

    Count unique codes by group

    Hi Chris, Hopefully this is what you are looking for (one of many ways): First transposing, then getting the unique group/counts and using proc summary to perform the counts. The completetypes and classdata options allow proc summary to retrieve the groups that have 0 codes. data have ...
  19. kdt82

    Complicated SAS date conversion issue

    The first thing I would do, is to check why date_num is being recognised as a character datatype. The most likely culprit is a length statement with $. You can determine the variable type at run time with the vType function (returns C for character variables, and N for numerics). This should...
  20. kdt82

    How to sum up data in batches by a var

    Don't know much about DDE, but normally if I had to do some heavy VBA manipulation, I prefer to code in the spreadsheets VBA editor directly. You can however use the ODS Excel tagset to create the named tabs. You might want to read up on the styles you can use with this for further...

Part and Inventory Search

Back
Top