Hi I have imported a data file from CSV fromat which have 28243 rows and 2296 varables using following code:
PROC IMPORT OUT= Ggp1
DATAFILE="G:\seleg.csv"
DBMS=csv REPLACe;
GETNAMES=YES;
DATAROW=2;
guessingrows=32767
Run;
Now I'm running follwong code:
data work.Ggp1;
set work.Ggp1;
array _v{*} v:;
if x1 > 1 then
do i = max(815,x1) to min(dim(_v),xx1);
_v{i} = 2;
end;
drop i;
run;
the log shows that the program has run successfully and shows no error message. But I check the data file, I don't see any change in the data file, can you tell my how to fix this problem?
I would recommend changing the second step such that it creates a new data set, not overwriting the imported data set and then checking.
Please post the log, one check is to make sure your loop condition is ever executed.
data work.check_condition1;
set work.Ggp1;
if x1 > 1 then output;
run;
hi,
thanks a lot. the attachment contains the CSV file, would you pls check that? mainly I intended to recode the variavbles starts from v815 to v1360, depending the values of x1 and xx1.
the log:
data sasuser.ggp2;
2472 set sasuser.ggp1;
2473 array _v{*} v:;
2474 if x1 > 1 then
2475 do i = max(815,x1) to min(dim(_v),xx1);
2476 _v{i} = 5;
2477 end;
2478 drop i;
2479 run;
NOTE: There were 474 observations read from the data set SASUSER.GGP1.
NOTE: The data set SASUSER.GGP2 has 474 observations and 671 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds
2480 data work.check_condition1;
2481 set sasuser.ggp1;
2482 if x1 > 1 then output;
2483 run;
NOTE: There were 474 observations read from the data set SASUSER.GGP1.
NOTE: The data set WORK.CHECK_CONDITION1 has 37 observations and 671 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
I think the other suggestion of the do loop conditions is correct, once your log is examined.
Your log shows 671 variables. So I have no idea what X1 is, but assuming it takes a value within the range of 1 to 671 the max condition always evaluates to 815 and then whatever the lower interval is, but that loop will never execute. Test the condition again with a put statement.
do i = max(815,x1) to min(dim(_v),xx1);
NOTE: The data set SASUSER.GGP2 has 474 observations and 671 variables.
Check the log to see if the loop is ever entered. You could also need a BY -1 if you plan to count down, but then I think the variable i won't be a valid index for your array.
data sasuser.ggp2;
set sasuser.ggp1;
array _v{*} v:;
if x1 > 1 then
do i = max(815,x1) to min(dim(_v),xx1);
_v{i} = 5;
put 'In Do Loop';
end;
drop i;
run;
thanks a lot, thank you very much for your cooperaion.....
There's one additional check to make, concerning this range:
do i = max(815,x1) to min(dim(_v),xx1);
Have you checked that max(815,x1) is actually less than or equal to min(dim(_v),xx1) ??
yep, x1 is less than or equal to xx1.
hi, the attachment contains the CSV data file.
It's not enough to verify that x1 <= xx1.
Even when x1 <= xx1, the DO loop may be starting at 815, not at x1.
You have to check for the actual conditions that your program uses. Are there any observations where:
max(815,x1) <= min(dim(_v),xx1)
I'm really very new, would u please tell me what does max(815,x1) mean practically?
wha does the hole statement mean? max(815,x1) <= min(dim(_v),xx1)
As Reeza mentioned, max(815, x1) means whichever is larger (815 or x1).
Similary, min takes whichever is smaller (but omits missing values). So min(dim(_v), xx1) means take whichever is smaller, either the number of elements in the array or the value of xx1.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: