BookmarkSubscribeRSS Feed
sasviyajunior
Calcite | Level 5

Hello. I tested with sashelp.class data
In the process. From class last line
I want to make this rule YY NN YY NN.
Is there a good way?
For example, you want to create a new column N YY NN YY NN in the class dataset.

4 REPLIES 4
mkeintz
PROC Star

I have absolutely no idea of what you are asking for.   Please provide (in the form of a DATA step with actual sashelp.class data) what you want the resulting data set to look like.  We all know what the 19 observations in sashelp.class looks like, so please show the (presumably) 19 rows of new variables.  And help us understand what rules you want to implement.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
sasviyajunior
Calcite | Level 5

I want the rules like YY, NN, YY, NN to be created as new columns by two rows from the last row.

mkeintz
PROC Star

Yeah, you said that before but I'm too dense to know what you mean.  Why not make it completely apparent and show us what the 19 rows resulting from sashelp.class would look like?  Are us just saying to make one new variable, which has character values "YY" for rows 1,3,5,,...19.   And value "NN" for rows 2,4,6,8,...18?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ballardw
Super User

@sasviyajunior wrote:

Hello. I tested with sashelp.class data
In the process. From class last line
I want to make this rule YY NN YY NN.
Is there a good way?
For example, you want to create a new column N YY NN YY NN in the class dataset.


Are N YY NN YY NN supposed to be variable names? Values? If values for how many variables? Of what names? If the values are YY or NN what is the rule in determining which is which.

 

Here is an example of executing some code only 2 records prior to the end of a given data set using SASHELP.CLASS.

data junk;
   set sashelp.class nobs=nn;
   if _n_ = nn-2 then do;
      var1='YY';
      var2= 3;
   end;
run;

But I don't see a lot of utility in this approach.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 500 views
  • 0 likes
  • 3 in conversation