Dear All,
I have some text Like that.
Q1. Which among the following are cor-
rect about the provisions of the Govern-
ment of India Act, 1858?
(a) It ended the system of double government by abol-
ishing the Board of Control and Court of Directors
(b) It also provided for the establishment of new legis-
lative councils for Bengal
(c) It reconstituted the Council of the Governor-General
(d) The number of additional member in the Provincial
Legislative Councils was also increased
Ans: (a)
I need your support how to show the data below format.
Question | A | B | C | D | Ans |
Which among the following are cor- rect about the provisions of the Govern- ment of India Act, 1858? | It ended the system of double government by abol- ishing the Board of Control and Court of Directors | It also provided for the establishment of new legis- lative councils for Bengal | It reconstituted the Council of the Governor-General | The number of additional member in the Provincial Legislative Councils was also increased | A |
store in text file in my systems
data work.question;
infile cards dlm= '? ()';
input Q $optiona $ optionob $ optionc $optiond $ correctans;
cards;
Q1. Which among the following are cor-
rect about the provisions of the Govern-
ment of India Act, 1858?
(a) It ended the system of double government by abol-
ishing the Board of Control and Court of Directors
(b) It also provided for the establishment of new legis-
lative councils for Bengal
(c) It reconstituted the Council of the Governor-General
(d) The number of additional member in the Provincial
Legislative Councils was also increased
Ans: (a)
;
run;
For files like these the full pattern is very important.
Is it guaranteed to follow that structure? You can't have short answer or fill in the blank type questions? You always have options A, B, C, D? No chance of just A, B, C or ABCDE?
options compress=yes;
data have;
infile 'c:\temp\test.txt' lrecl=2000;
length temp $ 32767 question a b c d ans $ 2000;
retain temp question a b c d;
input;
temp=cats(temp,_infile_);
if _infile_ =: '(a)' then do;
question=substr(temp,1,find(temp,'(a)')-1);
temp=substr(temp,find(temp,'(a)'));
end;
if _infile_ =: '(b)' then do;
a=substr(temp,1,find(temp,'(b)')-1);
temp=substr(temp,find(temp,'(b)'));
end;
if _infile_ =: '(c)' then do;
b=substr(temp,1,find(temp,'(c)')-1);
temp=substr(temp,find(temp,'(c)'));
end;
if _infile_ =: '(d)' then do;
c=substr(temp,1,find(temp,'(d)')-1);
temp=substr(temp,find(temp,'(d)'));
end;
if _infile_ =: 'Ans:' then do;
d=substr(temp,1,find(temp,'Ans:')-1);
ans=substr(temp,find(temp,'Ans:'));
output;
end;
drop temp;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.