2016-08-01 43 views
1

刪除其餘的觀察我有一個名爲b關於命名爲a1a2a45a345a999a654各種客戶數據集等。選擇A1-A100的觀察與在SAS

我想選擇客戶命名在a1 - a100之間並丟棄其他人。 我試過這段代碼:

data a; 
set b; 
where customer ne a1-a100; 
run; 

但我收到此錯誤

ERROR: Variable a1 is not on file b.

回答

2

轉換數字在你的客戶識別號碼,並適用於這個數字的條件。

data a; 
    set b; 
    if 1 le input(substr(customer,2),8.) le 100; 
run; 
  • substr(customer,2),8.返回的二維超聲心動圖,直到最後一個字符從customer,即數字
  • input(substr(customer,2),8.) interpretes數字爲數字
  • 1 le input(substr(customer,2),8.) le 100是寫input(substr(customer,2),8.) between 1 and 100的SAS方式(它是實際上更好,因爲它允許使用lt而不是le
  • if沒有then在這種情況下相當於where
+0

感謝它的工作,但我不明白這個代碼請解釋是否陳述 – bhavnish