BookmarkSubscribeRSS Feed
xiaolufan
Calcite | Level 5

I am using University Edition, and tried to limit observations in line 78.

I just want to have the output which only contains the "self" in variable V103.

and also want to drop rows, do I have to write down each row name, or is there any convenience way.

 

here is my log file.

 

 

 

 

61 proc import out=dataset3
 
62 datafile= '/folders/myfolders/Project/09836-0003-Data.'
63 dbms=sav
64 replace;
65
 
NOTE: The import data set has 31827 observations and 89 variables.
NOTE: WORK.DATASET3 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.36 seconds
cpu time 0.24 seconds
 
66 data dataset3;
 
67 set dataset3;
68 NEWUCODE=input(UCODE,best32.);
69 drop UCODE;
70 rename NEWUCODE=UCODE;
71
 
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
68:16
NOTE: There were 31827 observations read from the data set WORK.DATASET3.
NOTE: The data set WORK.DATASET3 has 31827 observations and 89 variables.
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.09 seconds
 
72 data dataset3;
 
73 retain UCODE V103 V104;
74 set dataset3;
75
 
NOTE: There were 31827 observations read from the data set WORK.DATASET3.
NOTE: The data set WORK.DATASET3 has 31827 observations and 89 variables.
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.08 seconds
 
76 data dataset3;
 
77 set dataset3;
78 if V103 ne self then delete;
79
 
NOTE: Variable self is uninitialized.
NOTE: There were 31827 observations read from the data set WORK.DATASET3.
NOTE: The data set WORK.DATASET3 has 68 observations and 90 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.04 seconds
 
80 data dataset3;
 
81 drop V108 V116 V117 V201 V202 V203 V207 V210 V211 V212 V216 V217 V218 V221 V221A;
82 set dataset3;
83
84
 
NOTE: There were 68 observations read from the data set WORK.DATASET3.
NOTE: The data set WORK.DATASET3 has 68 observations and 75 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.02 seconds
 
85 proc means;
 
86 run;
 
NOTE: There were 68 observations read from the data set WORK.DATASET3.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.30 seconds
cpu time 0.30 seconds
6 REPLIES 6
xiaolufan
Calcite | Level 5

i was tried to add the quotes, but there is another error that is:

 

ERROR: Variable V103 has been defined as both character and numeric.
Kurt_Bremser
Super User

@xiaolufan wrote:

i was tried to add the quotes, but there is another error that is:

 

ERROR: Variable V103 has been defined as both character and numeric.

Look at your data. If V103 is numeric, it makes no sense comparing it to the string "self".

Use proc contents on the input dataset(s).

rcrs2
Calcite | Level 5

You can just replace line 78 with this:

 

if V103='Self';

 

 

xiaolufan
Calcite | Level 5
it still shows that ERROR: Variable V103 has been defined as both character and numeric.
rcrs2
Calcite | Level 5

Try using the put() function to transform V103 into a string variable. I find a solution to that error in the following URL:

 

https://communities.sas.com/t5/Base-SAS-Programming/Variable-has-been-defined-as-both-character-and-...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1835 views
  • 0 likes
  • 3 in conversation