开发者

regarding the meaning of "put" in SAS

开发者 https://www.devze.com 2023-02-08 08:30 出处:网络
what does the following SAS statement mean? select(substr(put(customerID, 4.),3,2)); Especially, what do the three parameters 4., 3, and 2 stand for?开发者_JAVA百科 ThanksYou are first converting c

what does the following SAS statement mean?

select(substr(put(customerID, 4.),3,2));

Especially, what do the three parameters 4., 3, and 2 stand for?开发者_JAVA百科 Thanks


You are first converting customerID to a character format so that you can extract a string from it using the substr function.

put(customerID, 4.)

Converts a numeric value to a character value of length 4.

substr(myvar,3,2)

Returns the substring of length 2, starting from position 3 (from the left) of string myvar. In SAS, the very first character on the left is position 1, compared to most other programming languages and the world of computer science where you start with 0. myvar MUST be a character (string) variable.

I'm not familiar with the select() function, but your question seemed geared towards the substr and put functions.


The SELECT looks like it is part of a case statement where your logic will branch depending upon what is contained in the select function:

Example:

select (a);
   when (1) x=x*10;
   when (2);
   when (3,4,5) x=x*100;
   otherwise;
end;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号