Hello,
I have a silly question. I saw people use proc format and then build new variable with it.
I saw some used
Region = put(parkcode, $reglbl.);
but some used
Region=put(parkcode, ?? reglbl.)
what are the difference. I am very confused on '??' part. Could anyone guide me on this?
Thanks.
... View more
Hello,
I have multiple datasets with different col numbers.
I would like to rename each data set as:
1. 1st col as "label"
2. 2nd col to last col="Col1" to "Coln";
where n= colum position-1;
How can I rename data set without doing rename 1 by 1?
Any suggestion?
... View more
Hello
I want to do row calculation with the following rule:
The calculation is done per ID.
IF Y(Y= score, std) ) in time 1 is null and Y in time 2 and 3 are not null then Y in time 1 will be equal to Y in time 2* time 3.
Otherwise Y remain as is.
What is the way to do it please?
Data have;
input ID time score std;
cards;
111 1 . .
111 2 . .
111 3 7 5
222 1 4 6
222 2 5 7
222 3 4 8
333 1 . .
333 2 6 2
333 3 7 4
444 1 . .
444 2 6 4
444 3 7 2
;
Run;
expected output will looks like below:
ID
time
score
std
111
1
.
.
111
2
.
.
111
3
7
5
222
1
4
6
222
2
5
7
222
3
4
8
333
1
42
8
333
2
6
2
333
3
7
4
444
1
42
8
444
2
6
4
444
3
7
2
... View more
thanks so much!
I am new to sas. Please pardon me if my question is too silly : Do we have to do array? Is it possible to directly use value from fnt.fnt_1 to fnt_4?
... View more
hello,
I have a file for footnotes, like below:
data fnt;
length fnt_1 $80 fnt_2 $80 fnt_3 $80 fnt_4 $80;
infile datalines dlm=',' ;
input fnt_1 fnt_2 fnt_3 fnt_4 ;
datalines;
"Teach us the most important lessons in life", "Give the best advice and know the right thing to say." ,"Given us two of the best things we could ever have: life and love.", "Loved us unconditionally"
;
run;
I would like to use do loop to write my footnotes. I had my codes as:
data _null_;
set fnt;
do i=1 to 4.;
call execute( cat( "footnote"
, i
, " j = l "
, fnt_i
, " ;"
)
) ;
end ;
run;
However I got errors as below. 1-4 were added to footnote, but I could not get the value of fnt_1 to fnt_4 out.
Could anyone guide me on this? Ideal outcome is I can generate the line as:
footnote1 j=l "Teach us the most important lessons in life";
footnote2 j=l "Give the best advice and know the right thing to say.";
Thanks.
... View more
Thanks for the input. Do you mean two ' in "/^'\s*'$/" should not be allowed? I did have difficulty understand why there are ' ' in the code and the next line they have " ". In my mind, even the first one is correct, ''="" in most of the place, why there are two lines? what is the benefit to do repeat this process on resolve( footnote( _n_ ))?
... View more
Hello,
I am new to regular expression and feel lost when I try to understand the pattern that are described in this format.
I see a follwoing codes and could not understand what they means. Could anyone guide me on this?Thanks.
footnote( _n_ ) ne " " and prxmatch( "/^'\s*'$/" , strip( footnote( _n_ ))) = 0 and prxmatch( '/^"\s*"$/' , strip( footnote( _n_ ))) = 0 and resolve( footnote( _n_ )) ne " " and prxmatch( "/^'\s*'$/" , strip( resolve( footnote( _n_ )))) = 0 and prxmatch( '/^"\s*"$/' , strip( resolve( footnote( _n_ )))) = 0
what "prxmatch( "/^'\s*'$/" , strip( footnote( _n_ ))) = 0" mean?
whether it is same as " prxmatch( '/^"\s*"$/' , strip( footnote( _n_ ))) = 0"?
why we need "resolve( footnote( _n_ )) ne " "" and then repeat prxmatch process?
... View more
Hello,
I have a dataset which has 3 level of 'Subject' and 5 levels of 'test'. I would like to create a looping code to create summary tables by utilize an exisiting macro 'get_sum'. How can I do that.
I am thinking of sth like below:
do i=1 to 3;
do j=1 to 5;
%get_sum(indata=have; subset=subject eq i and test eq j);
end;
end;
I am new to sas and not sure how to handle looping situation. Could anyone guide me on this?
... View more
Hello All,
I'm trying to assign unique id based on the info from var1 and var2. Not sure how to do it. New variable 'id' will restart from 1 when var1 changed.
sample data:
data have; input var1 var2; datalines; 1 1 1 1 1 3 2 1 2 2 2 2 2 5 ; run;
Thank you!
... View more
Hello,
I have a have dataset, I want to create a group seq based on:
if id is the same;
if yn=1 and seq are connected to each other, then they belong to same group;
How can I create new_seq?
sample data:
data have ; input id seq yn ; cards; 1 1 . 1 2 . 1 3 1 1 4 1 1 5 . 1 6 . 1 7 . 1 8 1 1 9 1 1 10 1 1 11 . 1 12 . 1 13 1 1 14 1 1 15 . 1 16 1 1 17 1 2 1 1 2 2 . 2 3 1 2 4 1 2 5 . 2 6 . 2 7 1 2 8 1 2 9 .
;
... View more
Hello,
I would like to assign seq number for each id's each "stop" activity group . if two stops are back to back, it will be counted as 1. how can I create "sseq" using example dataset ds1?
data ds1 ; input id seq stop; cards ; 1 1 0 1 2 1 1 3 0 1 4 0 1 5 1 1 6 1 2 1 0 2 2 0 2 3 1 2 4 1 2 5 1 2 6 0 2 7 1 2 8 0 2 9 1 ; run;
The expected output:
Thanks.
... View more
Hello,
I would like to get var list that start with certain pattern from sample data. for example, variables start with 'Cr'. Currently I have following codes, but I was not able to utilize the macro variable that was set up for pattern, Could anyone tell me what I did wrong?
```
proc contents data=sashelp.baseball noprint out=_contents_; run;
%let np=Cr; /*macro variable for name pattern*/ data _contents1_; set _contents_(where=(upcase(name)=:'&np.')); run;
```
I tried "&np." and &np. and they are also not working.
Thanks.
... View more
the tricky part is the var 'trt' is not from 1-9, they are 1,3,4,5,6,7,99, so the new name will be COL+1,2,3,4,5,6,7. Is it possible to auto update 'variable with name started with trt' to name 'COL'+the variable order in the dataset?
... View more